in reply to Re: Cannot preserve Latin 2 character sets in Perl
in thread Cannot preserve Latin 2 character sets in Perl

OK.

I am editing on Windows XP Pro using Notepad++ and Dreamweaver. The file is being edited from a remote installation on a LAN that is an SME Server, a Linux distribution. I run the remote script using PuTTY. I usually have to change the translation settings on PuTTY to Latin 2 to get uncorrupted characters on output.

What I am trying to do is take output from MySQL and print up an HTML page that displays these Croatian characters. MySQL requires some tinkering to get it to handle these characters correctly and only a recent version past 5.0 will do it. But at this point the difficulty is taking the characters that have survived output from MySQL and print them to a page generated by Perl. So the code is something like:

$HTML = encode( "iso-8859-2", $HTML);

while (<OLD>) {
s!<body>.*</body>!<body>$HTML</body>!gs;
print NEW $_ or die "can't write $new: $!";
}

But this isn't working. The output has changed, but the characters are not being preserved. I am getting erroneous characters instead of little squares on browser output.

What am I missing?

  • Comment on Re^2: Cannot preserve Latin 2 character sets in Perl

Replies are listed 'Best First'.
Re^3: Cannot preserve Latin 2 character sets in Perl
by moritz (Cardinal) on Sep 30, 2011 at 06:48 UTC

      OK, this worked.

      I took a clue from your post and did the following. I changed the meta header from

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> to

      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />

      And I also changed the code from

      $HTML = encode( "iso-8859-2", $HTML); to

      encode( "iso-8859-2", $HTML);

      Now my Croatian characters are showing up like they are supposed to. I was additionally confused by the fact that my Notepad++ character settings were not showing the Croatian characters correctly. They show up fine in Dreamweaver.

      Thanks for the tips, everyone. I consider the problem SOLVED.