I have a number of UTF8 encoded strings in an xml database which I then load into a ValueTree, so far so good. But how do I then display these strings as they should be? String::fromUTF8 only seems to work for string literals.
E.g.
[code]DBG (String::fromUTF8 (CharPointer_UTF8 ("\xc9\x99\xca\x8a"))); // displays as expected əʊ
That doesn’t work either. I was casting to a char* as that seemed the closest thing to a string literal.
This is easily reproducible, or maybe I’m just approaching it in the wrong way. Simply store the string “\xc9\x99\xca\x8a” in a file called “testText.txt” on the desktop and run the code below. None of the options give the correct characters, only the string as it is stored in the file.
:oops: Now I feel silly, of course that isn’t going to work.
That isn’t what I was doing originally however. I had an Xml document with non-ascii characters that I added to the Introjucer, this very nicely converted it into UTF8 string literals for me. The problem was that it wouldn’t parse as Xml, I kept getting an “unmatched pairs” error but I’m pretty sure the Xml is good, it loads in Chrome fine.
Anyway, I’ve found a suitable work around for now, might come back to it at a later data.