in reply to why no default unicode?

If add an environment variable: set PERL5OPT=-CSD Perl will default STDIN/STDOUT/STDERR & all opens to use UTF-8 by default. Which may or may not be what you want.

See perlrun -C & Perlrun Environment variables for details.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: why no default unicode?
by perl-diddler (Chaplain) on Mar 20, 2011 at 00:00 UTC
    Well, I'd prefer it to use UTF-8 for the Term if there term is setup to use UTF-8 (i.e. as expressed by local).

    For files, it should probably default to binary unless told otherwise.

    Since all my terms are UTF-8, is how about a way to tell it to use UTF-8 on 'tty' devices, but default to binary on files? Too much intelligence built into the startup code, probably eh?...

    Either that, OR..."auto-switch": if detect widechar on output, then convert to UTF-8 bytes... That would be the most helpful -- since it knows I'm trying to output a wide-char, so it should (IMO) *try* to do the best it can and assume a UTF-8 output device...

    What would be the 'downsides' of that approach? (I.e. instead of the current approach of putting out a warning)...

      Read the linked documentation. If you don't want open to default to utf-8, then set PERL5OPT='-CS'

      As for auto-detecting. There is no way for perl (or any other language) to determine the difference between an input file containing utf-8, and an input file containing arbitrary binary.

      Indeed, there is no way to distinguish between utf-8 and utf-2 or utf-32 or arbitrary binary. In this respect the entire unicode standard is terminally broken.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.