-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Convert timezone to utf-8 on Windows #10281
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
Conversation
Previously rust-lang#9418 fixed utf-8 assertion issue by wcsftime, but the function didn't work as expected: it follows the locale set by setlocale(), not the system code page. This patch fixes it by manual multibyte-to-unicode conversion.
Hm, I was hoping that the last time around we would have some tests to exercise this functionality, but it appears that they weren't added. Is it possible to execute the unicode paths in tests? |
The actual problem is that Also, I'm going to disable |
Second patch is less related to pr title :-/ but anyway this correctly sets local time zone. |
// `SetEnvironmentVariable`, which `os::setenv` internally uses. | ||
// It is why we use `putenv` here. | ||
extern { | ||
#[link_name = "_putenv"] |
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.
Does this compile on linux and osx? I'm a little surprised that this needs the link_name
attribute. Why not just call the function fn _putenv
?
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.
I think this probably relies on our removal of obviously dead branches in the frontend, which might not be a good idea.
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.
Ah, I forgot #[cfg]
and cfg!
are different thing. This won't compile on non-windows.
#[link_name = "_putenv"]
is an artifact (I'll remove it!) from cancelled plan of using putenv on other platforms.
Previously #9418 fixed utf-8 assertion issue by wcsftime, but the function didn't work as expected: it follows the locale set by setlocale(), not the system code page. This patch fixes it by manual multibyte-to-unicode conversion.
Previously #9418 fixed utf-8 assertion issue by wcsftime,
but the function didn't work as expected: it follows the locale
set by setlocale(), not the system code page.
This patch fixes it by manual multibyte-to-unicode conversion.