Hello,

Thank you Brandon McCaig and John Delacour for your answers. They both
point me to my mistakes.

The major problem was that I did not understand at all how perl
deals with strings.

First I have to use "use utf8" if i want perl to understand 'é'
and not 'Ã' '©' when I write 'é' in my script. I did not realise
because the terminal turns 'Ã' '©' back to 'é'.

Second, when I want to talk to a terminal, I have to tell perl what
encoding the terminal is expecting by using the correct IO encoding
layer for the terminal.

And finally, the encode_json and decode_json functions are designed
to be quick functions that can **export** or **import** utf data over
binary IO channel and NOT to/from a terminal that needs some
additionnal encoding layer. So I should not be surprised to see 'é'
instead of 'é' on a terminal.

In the end,

- "use utf8"
- binmode( \*STDOUT, ':utf8' ). And in fact binmode( $channel, ':utf8' )
  for every channel that's opened to utf8 encoded text file.
- Only use encode_json and decode_json with binary communication channel
  since they already perform the utf transformation.

Thanks again,
Christophe

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to