summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-06-06 13:08:17 -0600
committerKarl Williamson <khw@cpan.org>2014-06-07 10:24:59 -0600
commit9717af6d049902fc887c412facb2d15e785ef1a4 (patch)
treebfc511fcbe55465cfb3b7d819deef013d3086724 /ext
parentf406a44534fb208bbd0ef2f84f722d1693b498a4 (diff)
downloadperl-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.xs9
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);
}
}