-
Notifications
You must be signed in to change notification settings - Fork 20
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
fixes ingydotnet/io-all-pm#93: -utf8 not applied everywhere. #98
base: master
Are you sure you want to change the base?
Conversation
…ieing as array ref.
Hi! Sorry it took us so long but the relevant commit seems to do with Tie::File and is not related here - see commit 21e63fa . Can you file a new pull-req? |
Hi! Sorry for the late reply but in the branch I am getting test failures:
can you look into fixing them? |
Ah, sorry! I can reproduce your issue and have found a working alternative. Will update my branch and let you know. |
1 similar comment
…tually in effect when selected.
Okay, I'm done. My new approach has Tie::File open the file itself and set the binmode, using that module's (unfortunately undocumented) 'discipline' option (see I have also expanded the tie_file test to verify the utf8 functionality a bit. |
Should we politely ask the owner of Tie::File to document the discipline option now? |
I went looking for a place to execute your suggestion, @akarelas, and I think I now know why they didn't mention it... UTF-8 support in Tie::File is seriously buggy! (However, I think they ought to have warned about the bug instead, since the problem same no matter if one tie()s with my 'discipline' approach here or via an utf8-enabled filehandle as in the bug report above.) My test happened to exercise the one way that works: Appending multi-byte data to the end of the file. For instance, if line 1 has an "ä" (two-byte UTF-8 char) on it and you replace it with "a" (one byte), then there is an extra empty line before the old line 2. On the other hand, if there is an "a" and you replace it with "ä", the first character of line 2 is clobbered by the newline that now has moved to the right. The bug has been known and acknowledged but unfixed for 2 1/2 years, which implies that it isn't trivial. @shlomif, I'm not quite sure how we are to handle this problem in our module, until Tie::File is fixed. Maybe we should add a bold warning of our own that tie()ing in UTF-8 mode only is safe for reading? |
This pull request ensures correct encoding by first opening the file normally, with all encoding layers being applied, before its file handle is tied to an array reference.