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

glog print wchar_t? #64

Closed
qingzew opened this issue Oct 15, 2015 · 1 comment
Closed

glog print wchar_t? #64

qingzew opened this issue Oct 15, 2015 · 1 comment

Comments

@qingzew
Copy link

qingzew commented Oct 15, 2015

I write this code to print wchar_t using glog:

std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) {
    std::mbstate_t state = std::mbstate_t();
    int len = 1 + std::wcsrtombs(nullptr, &wstr, 0, &state);
    std::vector<char> mbstr(len);
    std::wcsrtombs(&mbstr[0], &wstr, mbstr.size(), &state);

    out << &mbstr[0];
    return out;
}

std::ostream& operator<<(std::ostream& out, const std::wstring& str) {
   return operator<<(out, str.c_str());
}

but it does not work, why??

@seanchann
Copy link

@sergiud sergiud closed this as completed Mar 30, 2021
@sergiud sergiud mentioned this issue May 6, 2021
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

3 participants