Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
I'm completely lost in encodings :(
I'm reading data using LWP. When the data contains umlauts, things start to get weird and I get lost.
As the whole script is already very complex, let me try to give examples first before I start thinking about an example script.
For the example I use perl debugger. <&p>
After reading my data one of the strings looks like this:
DB<11> x $str 0 'Künzler' DB<12> x Encode::is_utf8($str) 0 '' DB<13> x length($str) 0 8 DB<14> x substr($str,0,3) 0 'Kü'
So I think my issue already starts here as the data I read is displayed correctly but perl treats it as bytes.
I do not know what to do with that string so that perl handles it correctly.
DB<20> x Encode::decode('utf8', $str) 0 'K?nzler'
(It was the Questionmark on a square that was displayed). That seemed wrong, but when I tested by reading from an utf-8 file opening it with '<:utf8' I got the same result, so obviously it's correct that way.
So as a test I changed my string here by decoding it as utf8.
In the next step, the string is handed to MIME::Lite::TT::HTML and by that to Text::Table. Finally it's send to me by mail.
When I look at the mail's source, the umlaut is (quoted printable) represented by '=FC' and, unfortunately, displayed as a questionmark in a square :(
I know I should have some sample code, and I will try to write some, but I hoped that in the meantime someone here with more experience already has a hint for me, where to debug further or how to fix it.
As far as I know, Text::Table requires perl strings to properly format tables. But shouldn't my string be a perl string when decoded?
Many thanks in advance.
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Lost in encodings
by haj (Vicar) on Feb 07, 2020 at 20:29 UTC | |
by LanX (Saint) on Feb 07, 2020 at 20:36 UTC | |
by haj (Vicar) on Feb 07, 2020 at 21:08 UTC | |
by Your Mother (Archbishop) on Feb 07, 2020 at 21:22 UTC | |
by LanX (Saint) on Feb 07, 2020 at 21:37 UTC | |
| |
by LanX (Saint) on Feb 07, 2020 at 21:13 UTC | |
by LanX (Saint) on Feb 08, 2020 at 18:15 UTC | |
by Skeeve (Parson) on Feb 07, 2020 at 23:41 UTC | |
by LanX (Saint) on Feb 08, 2020 at 12:14 UTC | |
by Skeeve (Parson) on Feb 10, 2020 at 07:48 UTC | |
by haj (Vicar) on Feb 10, 2020 at 15:41 UTC | |
Re: Lost in encodings
by LanX (Saint) on Feb 07, 2020 at 20:16 UTC | |
Re: Lost in encodings
by LanX (Saint) on Feb 07, 2020 at 19:46 UTC | |
Re: Lost in encodings
by misc (Friar) on Feb 10, 2020 at 06:35 UTC |