| Newsgroups |
perl.unicode |
| Message-ID |
<[email protected]> |
[email protected] wrote:
>
>
> > Now, in spite of Devel::Peeks label, it seems that perl's internal data
> > is utf-8. I am just curious as to why a :raw binmode would change the
> > data. If indeed it is, I am after all just guessing here.
> >
>
> I've seen bugs caused by utf-8 magically turning into iso-latin-1 (and
> sometimes leaving the utf-8 flag set), but that might not be what is going
> on here. (And I haven't seen that lately.)
Heh, I was rather hoping someone would be pointing out I was a typical noob rather than a perl bug :)
> What locale are you running in? I'm wondering if changing that will have an
> effect. If you aren't in a utf-8 locale, maybe you could try it.
LANG is set to en_GB.
With some messing about I have managed to create an en_GB.utf8.
Setting LANG to that makes no difference to the perl output, as does setting LC_ALL.
Mind you, I should hope it wouldn't as :raw ignores locale, apparently.
In a nutshell, the code below should put \xc3\x84 into the output file and
not \xc4 as it is doing. Well, I presume it should and no one is saying otherwise.
#!/usr/bin/perl -w
use Encode(_utf8_on);
my $data = "\xC3\x84";
_utf8_on($data);
open FH, ">aa";
print FH $data ;
print length($data);
Thanks for your time.
John