diff options
-rw-r--r-- | locale.c | 10 | ||||
-rw-r--r-- | perl.c | 5 |
2 files changed, 15 insertions, 0 deletions
@@ -474,6 +474,16 @@ Perl_init_i18nl10n(pTHX_ int printwarn) #endif /* USE_LOCALE */ { + /* Set PL_wantut8 to TRUE if any of the following are true: + - nl_langinfo(CODESET) contains /^utf-?8/i + - $ENV{LANGUAGE} contains /^utf-?8/i (only if using glibc) + - $ENV{LC_CALL} contains /^utf-?8/i + - $ENV{LC_CTYPE} contains /^utf-?8/i + - $ENV{LANG} contains /^utf-?8/i + If PL_wantutf8 is true the perl.c:S_parse_body() + will turn on the PerlIO :utf8 discipline on STDIN, STDOUT, + STDERR, _and_ the default open discipline. + */ bool wantutf8 = FALSE; char *codeset = NULL; #if defined(HAS_NL_LANGINFO) && defined(CODESET) @@ -1478,10 +1478,15 @@ print \" \\@INC:\\n @INC\\n\";"); if (!PL_do_undump) init_postdump_symbols(argc,argv,env); + /* PL_wantutf8 is conditionally turned on by + * locale.c:Perl_init_i18nl10n() if the environment + * look like the user wants to use UTF-8. */ if (PL_wantutf8) { /* Requires init_predump_symbols(). */ IO* io; PerlIO* fp; SV* sv; + /* Turn on UTF-8-ness on STDIN, STDOUT, STDERR + * _and_ the default open discipline. */ if (PL_stdingv && (io = GvIO(PL_stdingv)) && (fp = IoIFP(io))) PerlIO_binmode(aTHX_ fp, IoTYPE(io), 0, ":utf8"); if (PL_defoutgv && (io = GvIO(PL_defoutgv)) && (fp = IoOFP(io))) |