- This topic has 1 reply, 2 voices, and was last updated 8 years, 3 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Integrated Application Platform
Integrated Application Platform › Forums › General › Wcstombs – String Conversion
I’m trying to convert a USC-2 (UTF16) to UTF8 using the built in method Wcstombs
Example
temp = “”
temp = “Test”.Wcstombs()
Print(temp)
Result is an Exception
..\gcstring.cpp:224: assertion failure: cc->left.size() + cc->right.size() == -n
Any ideas?
I’m not sure why Wcstombs() is causing problems (I got an access violation when I tried your example). I assume it’s because the input is “bad”.
Your example is backwards – Suneido uses 8 bit character strings, so “Test” is (more or less) UTF-8 (= multi byte string = mbs).
s = “Test”.Mbstowcs()
=> “T\x00e\x00s\x00t\x00\x00\x00”
s.Wcstombs()
=> “Test”