Reputation: 311
I'll start by admitting that something very basic is going over my head here.
The input (from STDIN) to my Perl code is Ç (capital c with cedilla). I decode it by putting this line at the top of my code :
binmode STDIN, ":encoding(UTF-8)";
Once the user inputs 'Ç', I just print it. The output is \xC7. I understand perfectly that this is so because the Unicode code point for capital c with cedilla is U+00c7.
What should I do to get the printed output on STDOUT as 'Ç', i.e., convert the code point into the character?
I have also added this line to encode the output to STDOUT :
binmode STDOUT, ":encoding(UTF-8)";
Upvotes: 0
Views: 563
Reputation: 28060
You can do the same to STDOUT as you did to STDIN:
perl -e 'binmode STDOUT, ":encoding(UTF-8)";print chr(0xc7);'
prints
Ç
as required.
Upvotes: 2