in reply to deal with incorrectly set utf8 flag
It's not clear what you want.
utf8::downgrade switches from bytes internally encoded as UTF-8 to just bytes.
$ perl -MDevel::Peek -e'utf8::upgrade $x="\200\201"; Dump $x; utf8::do +wngrade $x; Dump $x' PV = 0x81623f0 [UTF8 "\x{80}\x{81}"] PV = 0x81623f0 "\200\201"\0
utf8::encode will re-encode the data that has been decoded from UTF-8.
$ perl -MDevel::Peek -e'utf8::decode $x="\x{2660}"; Dump $x; utf8::enc +ode $x; Dump $x' PV = 0x81651c0 [UTF8 "\x{2660}"] PV = 0x81651c0 "\342\231\240"\0
If it's truly an incorrectly set flag, there's also Encode::_utf8_off. It should only be used if the above two don't work.
$ perl -MDevel::Peek -MEncode=_utf8_on,_utf8_off -e'_utf8_on( $x="\200 +\201" ); Dump $x; _utf8_off $x; Dump $x' PV = 0x81651e8 [UTF8 "\x{1}@"] PV = 0x81651e8 "\200\201"\0
References:
utf8 (You don't need to load the module to use its subs.)
Encode
Update: Added code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: deal with incorrectly set utf8 flag
by Anonymous Monk on Mar 27, 2009 at 16:37 UTC | |
by ikegami (Patriarch) on Mar 27, 2009 at 16:40 UTC | |
by Anonymous Monk on Mar 27, 2009 at 16:48 UTC | |
by ikegami (Patriarch) on Mar 27, 2009 at 16:53 UTC |