in reply to Converting Unicode
When it's someone else's code, however, the situation becomes more problematic. Be careful which modules you choose to incorporate.use utf8; #FOR THE "wide characters" IN YOUR OWN CODE binmode STDIN, ":utf8"; #FOR INCOMING UTF8 binmode STDOUT, ":utf8"; #FOR OUTGOING UTF8 binmode STDERR, ":utf8"; #AND FOR ERRORS SEPARATELY use open qw/:std :utf8/; #THIS ONE CAN BE PROBLEMATIC WITH DATA +BASE INTERACTIONS use open ':encoding(utf8)'; #ANOTHER WAY OF SAYING IT use feature 'unicode_strings'; #ANOTHER PART OF 'TMTOWTDI' FOR PERL U +NICODE
Of course, if these options fail, and the UTF8 characters are not quintessential to your application, you can also remove them all and stick with a pure-ASCII solution. This may cause the least headache if UTF8 is not important to you. You could then use virtually any modules, and have no issue with any I/O operations. But it will not be very future-proof.
I look forward to the day when Perl has advanced to using unicode natively--by default. It's too bad that day is not already here.
See more here: https://perldoc.perl.org/perlunicode
Blessings,
~Polyglot~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting Unicode
by ikegami (Patriarch) on Dec 02, 2023 at 19:26 UTC | |
| |
|
Re^2: Converting Unicode
by Polyglot (Chaplain) on Dec 18, 2023 at 19:36 UTC | |
by 1nickt (Canon) on Dec 19, 2023 at 10:21 UTC | |
by Polyglot (Chaplain) on Dec 19, 2023 at 14:24 UTC | |
by hippo (Archbishop) on Dec 19, 2023 at 14:31 UTC | |
|