diff options
author | Karl Williamson <khw@cpan.org> | 2018-01-17 13:24:46 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-01-30 22:49:03 -0700 |
commit | 9fcdb54ca190652e65c92597e8d4822511a96d57 (patch) | |
tree | 3af6abaf3a66e42abad49f0db4d7f1ec459cc3b9 /ext | |
parent | a1395eaf50e445a5d48b26b960d58275dcffc265 (diff) | |
download | perl-9fcdb54ca190652e65c92597e8d4822511a96d57.tar.gz |
POSIX::strftime: Add better fallback about UTF-8
If the function returns a valid string that isn't completely UTF-8
invariant, the function assumes it is UTF-8 if we are in a UTF-8 locale.
This works, but in the unlikely event that the system has no LC_TIME, we
can't tesll if it is in a UTF-8 locale. As a better fallback position,
this commit adds the check that there is just a single script of the
time string, adding a measure of reassurance that out call that it is
UTF-8 is correct.
This is unlikely to be used, but now that there is a function to call
that determines if this is a script run, it's easy to add, and unlikely
to actually get compiled.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/POSIX/POSIX.xs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 82fba1fe30..d3bbfd8242 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -3571,6 +3571,12 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) || ( is_utf8_non_invariant_string((U8*) buf, len) #ifdef USE_LOCALE_TIME && _is_cur_LC_category_utf8(LC_TIME) +#else /* If can't check directly, at least can see if script is consistent, + under UTF-8, which gives us an extra measure of confidence. */ + + && isSCRIPT_RUN((const U8 *) buf, buf + len, + TRUE, /* Means assume UTF-8 */ + NULL) #endif )) { SvUTF8_on(sv); |