-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wcsftime instead of strftime for different locales (#27239) #27273
Conversation
base/libc.jl
Outdated
if Sys.iswindows() | ||
function wcsftime(fmt::AbstractString, tm::TmStruct) | ||
wctimestr = Vector{Cwchar_t}(undef, 128) | ||
n = ccall(:wcsftime, Csize_t, (Ptr{Cwchar_t}, Csize_t, Cwstring, Ref{Libc.TmStruct}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the Libc.
?
Add a test? |
base/libc.jl
Outdated
n == 0 && return "" | ||
return transcode(String, wctimestr[1:n]) | ||
end | ||
strftime(fmt::AbstractString, tm::TmStruct) = wcsftime(fmt, tm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than defining both strftime
and wcsftime
, you could just call the function strftime
. Currently you're effectively defining two identical functions on Windows.
Yep, I think test/misc.jl would be a fine place for it. 🙂 |
The comment from @ScottPJones is that this can happen in any system with different locales other than
So I changed the title. @kshyatt Could you remove the |
Currently
Edit: |
I added tests in |
Did I miss something? Why was this closed, @alkorang? |
@ararslan |
Happens to the best of us! |
Any chance this gets merged soon? Currently 0.7 is not really usable on Win 10 with non-english locale. Thanks! |
Let's rerun tests and merge when CI is green. |
It might be worthwhile to add a NEWS entry under "library improvements" or something, since this will be of interest for folks in other locales. |
Fix #27239
The problem was invalid UTF-8 characters from
strftime()
depending on Windows system locales.Solution is using
wcsftime()
to get UTF-16 andtranscode()
it into UTF-8 on Windows.