converting string from unicode
How can I convert a wchar_t* to a char* ??
I've tried all sorts of methods but nothing seems to work right.. ahhhhhhhhhh *kills self*
wcstombs().
Alternatively, just stick with unicode for everything. it's only going to make things easier as more and more libraries are workign exclusively with unicode.
Alternatively, just stick with unicode for everything. it's only going to make things easier as more and more libraries are workign exclusively with unicode.
UTF-16 is terrible. I doubt libraries won't start using it. Or at least I *hope* so... it seems like you can never overestimate the software industry. UTF-8 is superior in all ways but one (predictable data size).
UTF-8 is my preference. It has the advantage that it's 'backward compatible' with ASCII.
But I don't know why I'm saying this since the original poster killed himself.
But I don't know why I'm saying this since the original poster killed himself.
Considering that UTF-16 does represent some code points as surrogate pairs, UTF-16 isn't even superior to UTF-8 in the domain of "predictable data size".
Well in the theme of sticking totally with unicode, what I'm really trying to do is convert a string to a float.. so is there a unicode version of atof?
Quote:Original post by Dovyman
How can I convert a wchar_t* to a char* ??
I've tried all sorts of methods but nothing seems to work right.. ahhhhhhhhhh *kills self*
Quote:Original post by Dovyman
Well in the theme of sticking totally with unicode, what I'm really trying to do is convert a string to a float.. so is there a unicode version of atof?
Assuming your using c++ i not sure but what about the wide character version of stringstream? e.g.
#include <string>#include <sstream>#include <iostream>int main() { std::wstring s(L"0.545"); std::wstringstream wss(s); float f = 0.0f; wss >> f; std::cout << f << '\n'; return 0;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement