in reply to Recommended way to set the utf8 flag without altering the data

For perl 5.6.x, thus including UTF-8 support but not coming with Encode, you can use pack. In the following, the first character ("C" or "U") indicates the type of packed string, which will be used for the whole string, the second is a character/byte count of zero. "a*" packs the actual string data.

Actually, that will still work on perl 5.8.x, though the few (well hidden) functions in Encode are a valid alternative. See Messing with Perl's Internals. Somehow I get the feeling they don't like you to mess with this, yourself...

Replies are listed 'Best First'.
Re^2: Recommended way to set the utf8 flag without altering the data
by borisz (Canon) on Jun 27, 2004 at 12:38 UTC
    Thats a good tip too, I compared the three alternate forms and here are the results:
    Rate decode pack _utf8_on decode 57971/s -- -93% -95% pack 781250/s 1248% -- -30% _utf8_on 1111111/s 1817% 42% --
    Boris