http://qs1969.pair.com?node_id=138028


in reply to What is the proper way to deal with Char v. Byte Semantics

I have to say I had exactly the same problem trying to send UTF8 encoded XML stuff over HTTP (using Frontier::RPC2). Perl and me both got terribly confused over whether any given string was UTF8 or not.

This ended up being a complete nightmare especially since this code had to work on 5.5 and 5.6. In the end I worked out that something in Frontier::RPC2 was converting my strings to UTF8 behind my back under 5.6 whereas I had to convert them by hand in 5.5.

I experimented with 'use bytes' too but that didn't cut it either.

This code snipped might be useful

$unicode_perl = 1; { local $SIG{__DIE__}; eval "use utf8; 1" or $unicode_perl = 0; }
Altogether a very unpleasant experience which makes me think that 5.6 isn't really ready for UTF :-( Maybe 5.8 will be better in this regard.