Do you know where your variables are? | |
PerlMonks |
My UTF-8 text isn't surviving I/O as expectedby ibm1620 (Hermit) |
on Nov 23, 2024 at 20:14 UTC ( [id://11162851]=perlquestion: print w/replies, xml ) | Need Help?? |
ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:
I decided to join the 21st century and learn how to work with Unicode and UTF-8 encoding. I've included here a test Perl program that both contains literal UTF-8 text, and writes it into a sqlite DB, reads it back in, and prints it to STDOUT.
The advice given by brian d foy (https://stackoverflow.com/a/47946606/522385) and others has been to include the following two pragmas: But the following code produces garbage output on STDOUT unless I comment out both pragmas! The garbage I sometimes see is: Åke Lindström. If I paste and pipe that into `hexdump` I get
Other possibly-relevant info: I'm on MacOS Sequoia. I'm working in iTerm2.app, and I get the same behavior in Terminal.app. I've read perlunitut and https://perldoc.perl.org/open, probably not enough times. (Please note: I'm having trouble using UTF-8 text in this post, so unfortunately it's not going to look right. The text I'm trying to use, shown as a hex string, is "c3856b65204c696e64737472c3b66d". I fervently hope that, even without working code, someone can identify what I'm doing wrong.)
Back to
Seekers of Perl Wisdom
|
|