Skip to main content
gamedev.net
🔒 Locked

Convert Float/Double to Unicode String

Started by Shock 1 reply 650+ views
Original Post
Shock
Shock
Hello, I would like to know how I can convert a float or double to a Unicode String. I know there is swprintf, and there are conversion functions that VC++ has for converting it to MultiByte strings. But how can I do a direct conversion? Thanks
Zahlman
Zahlman
If you want UTF-8 encoding, then just do it as if you weren't using Unicode; the characters used for representing numbers all fall in plain 7-bit ASCII, and UTF-8 is ASCII-transparent.

If you want UTF-16, it will be easier to do it in the two steps AFAIK.
SiCrane
SiCrane
Huh? Define direct conversion. swprintf() should give you a UCS-2 encoded wide character string, and the numbers should lie in the non-surrugate range, so the results should be UTF-16 compatible.

edit: in MSVC anyways.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.