Home » U++ Library support » U++ Core » String.Mid() and Unicode
Re: String.Mid() and Unicode [message #28667 is a reply to message #28665] |
Fri, 10 September 2010 11:23   |
|
jeremy_c wrote on Fri, 10 September 2010 10:36 | I know a given string is at position 10 (example) and is 3 characters long. I don't know if that's 3 Unicode characters or 3 ASCII characters.
It seems that String.Mid(pos, len) is returning 3 bytes of data, not 3 characters, is that correct? If so, how can I retrieve 3 characters from a string at position XYZ?
Jeremy
|
Hi Jeremy,
I am by far not an expert on the topic, but I believe you need WString for this. String really works with 8bit characters only, while WString encodes the characters to 16 bits. Little example: String s="aβ¢d€f";
WString w(s);
for(int i=0;i<s.GetCount();i++){
Cout()<<IntStr(s[i])<<" ";
}
Cout()<<"\n";
for(int i=0;i<w.GetCount();i++){
Cout()<<IntStr(w[i])<<" ";
}
(Well, the example was more to assure myself that I'am not talking nonsense )
Honza
|
|
|
Goto Forum:
Current Time: Mon Aug 25 23:11:53 CEST 2025
Total time taken to generate the page: 0.05959 seconds
|