It's hard to believe the one statement prints "absolutely fine", while the other prints garbage.
As it is, your code doesn't even compile. There are several typos, there is no Encode::utf8_encode(), you're calling your OO method as a regular function, you haven't specified what exactly MultiByteChar is, etc.
The following code works fine, in the sense that both prints output the same sequence of octets for $[Ee]ncodedString:
#!/usr/bin/perl -w use strict; use Encode; sub changeEncoding { my $stringToEncode = shift; my $EncodedString = Encode::encode("utf8", $stringToEncode); print " $EncodedString "; return $EncodedString; } sub getEncodedString { my $encodedString = changeEncoding("\x{2345}"); print $encodedString ; } getEncodedString();
(though changeEncoding is a misnomer, as it doesn't really change the encoding — rather, it simply encodes a string from Perl's internal (decoded) unicode form)
In reply to Re: MultiByte Char handling in perl
by Eliya
in thread MultiByte Char handling in perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |