Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 characters in filename for agg_png #87

Open
Darxor opened this issue Jul 27, 2021 · 8 comments
Open

UTF-8 characters in filename for agg_png #87

Darxor opened this issue Jul 27, 2021 · 8 comments

Comments

@Darxor
Copy link

Darxor commented Jul 27, 2021

I've noticed that agg_png doesn't handle UTF-8 in file names well.

Example

library(ragg)

file <- "русское_название.png"
agg_png(file)
plot(sin, -pi, 2*pi)
dev.off()

Above code produces a file named СЂСѓСЃСЃРєРѕРµ_название.png instead of русское_название.png, like grDevices::png would. If a path has a UTF-8 in folder names, device would fail to write with agg could not write to the given file error.

I've tried to wrap filename with enc2native or enc2utf8, but it doesn't seem to help.

Session info
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=Russian_Russia.1251  LC_CTYPE=Russian_Russia.1251   
[3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C                   
[5] LC_TIME=Russian_Russia.1251    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] ragg_1.1.3

loaded via a namespace (and not attached):
[1] compiler_4.1.0    tools_4.1.0       textshaping_0.3.5
[4] systemfonts_1.0.2
@thomasp85
Copy link
Member

Thanks for this, that is an error on my part as I don't handle encoding correctly on the input string...

@thomasp85
Copy link
Member

Can I get you to test the current development version and see if your issue is fixed?

@Darxor
Copy link
Author

Darxor commented Oct 10, 2021

Thanks for the attention on the issue!
I've tried current dev version, and the problem is still there.

Current session info:
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=Russian_Russia.1251  LC_CTYPE=Russian_Russia.1251    LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C                    LC_TIME=Russian_Russia.1251    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ragg_1.1.3.9000

loaded via a namespace (and not attached):
[1] compiler_4.1.1         tools_4.1.1            textshaping_0.3.5      systemfonts_1.0.2.9000

@thomasp85 thomasp85 reopened this Oct 11, 2021
@thomasp85
Copy link
Member

hmm... in that case it is a bit more complicated... Windows have never been particularly kind to UTF-8 😕

I'll try to see if I can come up with a fix

@thomasp85
Copy link
Member

Can I get you to try with current level again?

@thomasp85
Copy link
Member

Also, can I get you to test with a tiff file as well? libtiff uses its own file open functions so I don't know if it exhibit the same issues

@Darxor
Copy link
Author

Darxor commented Oct 13, 2021

Issue for png seems to be solved now, yay!
Works nicely for png, jpeg and ppm now. But Its there for tiff though, you were right on checking that.

@thomasp85
Copy link
Member

Thanks for confirming - tiff is a more difficult mountain to climb so it will probably not get fixed for this release, but I'll look into a fix later.

Keeping this open to remind me

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

No branches or pull requests

2 participants