Skip to content

Use Windows wide APIs so Unicode paths work reliably#83

Closed
birenxiaofeigg-art wants to merge 7 commits into
JuliaIO:masterfrom
birenxiaofeigg-art:lxf/bugfix_open_png
Closed

Use Windows wide APIs so Unicode paths work reliably#83
birenxiaofeigg-art wants to merge 7 commits into
JuliaIO:masterfrom
birenxiaofeigg-art:lxf/bugfix_open_png

Conversation

@birenxiaofeigg-art

Copy link
Copy Markdown

This submission aims to solve the problem that “load()" cannot correctly load the .png file path in GBK encoding format.

@johnnychen94 johnnychen94 changed the title add compatibility of GBK format path for PNG file Use Windows wide APIs so Unicode paths work reliably Feb 27, 2026

@johnnychen94 johnnychen94 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. what is the minimal reproducible example of the bug? Test file, code snippet, output?
  2. make sure every bug fixes has associated test to avoid future regression

Comment thread src/wraphelpers.jl Outdated
Comment on lines +33 to +36
filename_utf16 = transcode(UInt16, filename)
push!(filename_utf16, 0) # add null terminator
mode_utf16 = transcode(UInt16, "rb")
push!(mode_utf16, 0)

@johnnychen94 johnnychen94 Feb 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this means "convert the filename using WChar type", and make sure the code is self-explanatory.

  • It's not immediately clear what transcode + push!(_, 0) means
  • You should use Cwchar_t instead of UInt16

Comment thread test/test_win_widechar_filename.jl Outdated
@@ -0,0 +1,6 @@
@testset "Images with wide char name" begin
img16 = PNGFiles.load("test_images/rgb测试16bit.png")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a random image, then we should probably just: randgen, write, rename to a Chinese filename, and then load back.

Keep tracking a 1.4M file in git history is too large for such a package.

Comment thread test/test_win_widechar_filename.jl Outdated

@test !isempty(img16)
@test eltype(img16) === ColorTypes.RGB{FixedPointNumbers.N0f16}
end No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add missing new line endings

@nhz2

nhz2 commented May 26, 2026

Copy link
Copy Markdown
Member

Thank you for the PR. This was fixed in #84

@nhz2 nhz2 closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants