diff options
author | Karl Williamson <khw@cpan.org> | 2014-06-06 13:08:17 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-06-07 10:24:59 -0600 |
commit | 9717af6d049902fc887c412facb2d15e785ef1a4 (patch) | |
tree | bfc511fcbe55465cfb3b7d819deef013d3086724 /ext | |
parent | f406a44534fb208bbd0ef2f84f722d1693b498a4 (diff) | |
download | perl-9717af6d049902fc887c412facb2d15e785ef1a4.tar.gz |
strftime: Set UTF-8 flag appropriately on return
The flag was only getting set if the format was in UTF-8. This looks at
the return values, and sets the flag if they are non-ASCII UTF-8 and, as
a further check, if the current locale is a UTF-8 one.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/POSIX/POSIX.xs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 797633406d..7161014262 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -1747,8 +1747,13 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) GCC_DIAG_RESTORE; sv = sv_newmortal(); if (buf) { - sv_usepvn_flags(sv, buf, strlen(buf), SV_HAS_TRAILING_NUL); - if (SvUTF8(fmt)) { + STRLEN len = strlen(buf); + sv_usepvn_flags(sv, buf, len, SV_HAS_TRAILING_NUL); + if (SvUTF8(fmt) + || (! is_ascii_string((U8*) buf, len) + && is_utf8_string((U8*) buf, len) + && _is_cur_LC_category_utf8(LC_TIME))) + { SvUTF8_on(sv); } } |