Sign in to follow this  

converting string from unicode

This topic is 4877 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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;
}


Share this post


Link to post
Share on other sites

This topic is 4877 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this