derion has asked for the wisdom of the Perl Monks concerning the following question:
This seems not work in the new environment.my $category; my $decoded_text = decode('UTF-8', $_); #my $latin1_html = encode('iso-latin-1', $decoded_text ); my $latin1_html = encode('iso-8859-1', $decoded_text ); if ($latin1_html =~ /behälter/i) { $category = 'Behälter'; }
before opening the file anduse open IN => ':encoding(UTF-8)'; use open OUT => ':encoding(iso-8859-1)';
This works at first sight but $category makes difficulties and seems to be another encoding than $_.my $category; if ($_=~ /behälter/i) { $category = 'Behälter'; }
my $category; if ($_=~ /beh\xE4lter/i) { $category = 'Behälter'; }
This works but it seems to be more a patch to a symptom than a cure to the problem. I really would like to understand what kind of mistake I am making and what approach I could take to handle file parsing, string modification and storing in files or databases the right way in the new environment. Thank you very much for your comments.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl encoding problem
by dave_the_m (Monsignor) on Dec 13, 2021 at 22:14 UTC | |
|
Re: Perl encoding problem
by kcott (Archbishop) on Dec 13, 2021 at 22:59 UTC | |
|
Re: Perl encoding problem
by ikegami (Patriarch) on Dec 13, 2021 at 23:24 UTC | |
|
Re: Perl encoding problem
by derion (Sexton) on Dec 14, 2021 at 00:25 UTC | |
by NERDVANA (Priest) on Dec 14, 2021 at 07:51 UTC | |
by derion (Sexton) on Dec 14, 2021 at 12:00 UTC | |
by NERDVANA (Priest) on Dec 15, 2021 at 14:17 UTC | |
by kcott (Archbishop) on Dec 14, 2021 at 00:56 UTC | |
by derion (Sexton) on Dec 14, 2021 at 13:50 UTC |