Syntactic Confectionery Delight | |
PerlMonks |
Re: help with cyrillic characters in odd placesby Anonymous Monk |
on Feb 06, 2019 at 13:29 UTC ( [id://1229478]=note: print w/replies, xml ) | Need Help?? |
Q1) Can I alter my perltidy command so that these chars are not problematic?This doesn't seem to be mentioned in perldoc perltidy, but see what I found in Perl-Tidy-20181120/docs/perltidy.html: -enc=s, --character-encoding=s where s=none or utf8. This flag tells perltidy the character encoding of both the input and output character streams. The value utf8 causes the stream to be read and written as UTF-8. The value none causes the stream to be processed without special encoding assumptions. At present there is no automatic detection of character encoding (even if there is a 'use utf8' statement in your code) so this flag must be set for streams encoded in UTF-8. Incorrectly setting this parameter can cause data corruption, so please carefully check the output. The default is none. The abbreviations -utf8 or -UTF8 are equivalent to -enc=utf8. So to process a file named file.pl which is encoded in UTF-8 you can use:
Regarding your Cyrillic path issues, Path::Tiny seems to work with file names as byte-strings, not character-strings. Allow me to demonstrate: $ ls -l итого 0 -rw-r--r-- 1 user user 0 фев 6 16:20 привет
$ perl -MData::Dump=dd -E'dd "привет"' pack("H*","d0bfd180d0b8d0b2d0b5d182")Data::Dump::dd output is the same for $path->children and a simple string consisting of UTF-8-encoded bytes. Perl wide characters are different when dumped using Data::Dump::dd or Data::Dumper::Dumper: $ perl -MData::Dump=dd -Mutf8 -E'dd "привет"' "\x{43F}\x{440}\x{438}\x{432}\x{435}\x{442}"You seem to be using an IOLayer to encode all characters being printed to STDOUT from wide characters to UTF-8. Since for Perl code, wide strings and byte strings are mostly same data type, except wide strings can have ord values > 255, encode doesn't really know whether it is encoding actual wide characters into UTF-8 or it is wrongly encoding UTF-8 bytes as if they were Unicode code points. So when you are trying to print file names, they undergo an unnecessary conversion and get garbled in the process. Your options include decode'ing them back into wide characters before printing (beware: filenames can contain invalid UTF-8 and arbitrary bytes!) or disabling the IOLayer that encodes the strings. with the advent of quantum computing, public key encryption would be passéSee Post-quantum_cryptography. This may be true for "classical" asymmetric cryptography which may be easy to break after we get powerful enough quantum computers (we don't, yet), but new approaches are already being developed that wouldn't rely on integer factorization / discrete logarithm / elliptic-curve discrete logarithm problems to be secure and also wouldn't be vulnerable to quantum computers.
In Section
Seekers of Perl Wisdom
|
|