If I interpret documentation ci=orrectly, perl --CSD
is suppose to ensure that input and output, processed or commands, are using UTF-8 encoding.
But if I replace two hyphens --
with an em-dash — (U+2014), the result is not rendered as an em-dash in UTF-8 locale in MacOS 12.1 (I don't have any other O.S. to try things on).
To avoid the chance of further encoding/rendering issues between upload, server, and client-side rendering, I'm showing a screen shot rather than pasting text:
If I open the file in an editor that assumes UTF-8 input, it displays the same. If I use that editor to add in another em-dash, the second one renders correctly, and is definitely encoded differently:
WGroleau@MBP ~ % od -xc /tmp/demo.txt
0000000 2049 6177 746e 6120 206e 6d65 642d 7361
I w a n t a n e m - d a s
0000020 2068 6562 7774 6565 206e 6874 7365 3a65
h b e t w e e n t h e s e :
0000040 4a20 656f a2c3 80c2 94c2 6f54 0a6d 2049
J o e â ** 302 200 302 224 T o m \n I
0000060 6177 746e 6120 206e 6d65 642d 7361 2068
w a n t a n e m - d a s h
0000100 6562 7774 6565 206e 6874 7365 3a65 4a20
b e t w e e n t h e s e : J
0000120 656f 80e2 5494 6d6f 0a0a
o e — ** ** T o m \n \n
Is there a bug, or am I doing something wrong? I need to automate several replacements in many files, and they contain multiple languages, so non-ASCI characters may be on the search side as well as the replacement side.
UPDATE: I do have access to a Debian system, but it's through ssh. I see the same thing with "perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux-gnu-thread-multi (with 65 registered patches …" but since I'm connected remotely, it's still being rendered by my system.
My perl is "perl 5, version 34, subversion 0 (v5.34.0) built for darwin-thread-multi-2level" with no mention of patches.
I'm open to another tool instead of perl, if it doesn't require a much bigger script or hours of learning a new language. There are already several languages I could do this in, but none of them are particularly convenient for this purpose.
O
flag of-C
cause the "input" (I'm unsure about the exact definition/scope of "input" I'm talking about here) to be treated as Unicode code point for every single byte: ix.io/3MDY