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

Hello,
I have small problem or some think like this :-))


I have some string with some native code (like ISO 8859-2,Latin 2 ....).

exam. $foo = "print 'foooo $_1 barbar"

and I use eval on $foo.
the problem is how to recode $foo into UTF16 or some others
if I want use eval on $foo

All strings in $foo is loaded from file.

THX for all messages

PS: Ithink there is no problem with encode from one ISO or win encoding to another but to UTF16 (ucs2,utf8)
MamuT

Replies are listed 'Best First'.
Re: Character Recode Perlcode
by tachyon (Chancellor) on Oct 01, 2001 at 16:25 UTC
      There is a problem:

      If I recode string "print 'foo'" to UTF16, I will get "\0p\0r\0i\0n\0t\0 \0'\0f\0o\0o\0'" and if I eval that string, I will get nothing, as the first "\0" will effectively ends the string. Similar problem exists with UTF8.

      There is no problem recoding string, egighter Text::Iconv or Unicode::String with Unicode::Map8 can be used, but there is problem evaling UTF8/UTF16 string.