ericlee has asked for the wisdom of the Perl Monks concerning the following question:

One of my scripts converts a UTF-8 encoded file with Norwegian language text into iso-8859-1 (for RSS feeds that are used by websites which don't yet use Unicode). Using Text::Iconv, it works fine with lower-case characters, but not with uppercase ones. A single upper case character in the line will cause a problem.

My relevant lines of code are:

if ($langcode eq "no") {$converter = Text::Iconv->new("utf-8", "iso-8859-1");}

and

$Header = $converter->convert("$Header");

It's a shared server and I don't control which Perl modules are available. The web host is 1&1 Internet.

Any ideas? Thanks very much.

Eric Lee
  • Comment on iconv Norwegian upper case - not working?

Replies are listed 'Best First'.
Re: iconv Norwegian upper case - not working?
by moritz (Cardinal) on Jun 18, 2009 at 11:12 UTC
    Since Encode is a core module, you should be able to use its from_to sub, which I've never had any problems with.

    If the problem still persists, it would be helpful to have hexdump of how that one character is stored, and what exactly the output looks like.

Re: iconv Norwegian upper case - not working?
by ikegami (Patriarch) on Jun 18, 2009 at 13:48 UTC

    Are you sure the character in question exists in iso-8859-1?

    Your feed generator generator should be doing the encoding, using XML entities for characters the encoding can't handle.