in reply to When is the utf8-flag turned on?

Usually only when a string is operated on with data that itself has the utf8 flag on. In perl5.8.0 (but not any later version) this can include input from a file if you are using a utf8 locale.

Once the flag is on, does

use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper $string;
show any > 8bit characters? (e.g. "foo\x{1ff}bar"). If so, where does it come from? If not, upgrading perl, using a non-utf8 locale, or binmode'ing your input filehandles may help.

Replies are listed 'Best First'.
Re^2: When is the utf8-flag turned on?
by uwevoelker (Pilgrim) on Aug 20, 2004 at 20:22 UTC
    I'm not using an utf8 locale, nor does I use 'use utf8'.
    My strings do not contain > 8 bit characters, but they contain 8 bit characters (German "Umlaute" - ä, ö, ü, ß).
      I'm not using an utf8 locale, nor does I use 'use utf8'.
      The comment about 'use utf8' here makes me think it's just possible you are mistaken. "Using a utf8 locale" isn't a perl thing, it's an operating system thing, and several OS's have taken to setting utf8 locales as a default. Check your environment variables LANG, LC_CALL, LC_CTYPE, and LANGUAGE.

      If that's not it, you'll have to dig a little bit into what happens to this variable; at what point does it get the utf8 flag turned on?