Skip to content
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

Windows 10 RS4 supports locale ".utf8" already, I wonder why setlocale doesn't make fmt::print with L-string work? #1229

Closed
denchat opened this issue Jul 14, 2019 · 2 comments

Comments

@denchat
Copy link
Contributor

denchat commented Jul 14, 2019

Now we can do this std way on Windows 10 v1803 or later

std::setlocale(LC_ALL, "en_US.utf8");
wprintf(L"zß水");

but fmt::print still do need this :

_setmode( _fileno(stdout), _O_WTEXT );

Otherwise, it only prints 'z'.

I wonder why? Is there some performance hits to support setlocale like wprintf?

@denchat
Copy link
Contributor Author

denchat commented Jul 14, 2019

I just realize this works without _setmode

fmt::print(std::wcout,L"zß水\n");

Shouldn't fmt::print select wcout seemlessly? Why?
Is fmt::print with _setmode faster than fmt::print(std::wcout ?

@vitaut
Copy link
Contributor

vitaut commented Jul 14, 2019

I wonder why?

As a library function print shouldn't be changing the global locale, because this could mess up user assumptions. This should be done on the application level.

Shouldn't fmt::print select wcout seemlessly?

Last time I checked writing via iostreams added nontrivial overhead. But you can easily write a formatting function that writes to wcout instead of stdout by default yourself.

@vitaut vitaut closed this as completed Jul 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants