jerra
asked on
C#, problem with Unicode conversion. (.NET 4)
I just can't get this working.
I have a string read from a source, for example "0038003800380038" which is Unicode. Thing is that the Unicode escape character is missing. I want to convert it to ASCII (8888). How do I do it?
"0038003800380038" -> "\u0038\u0038\u0038\u0038" -> "8888"
I have a string read from a source, for example "0038003800380038" which is Unicode. Thing is that the Unicode escape character is missing. I want to convert it to ASCII (8888). How do I do it?
"0038003800380038" -> "\u0038\u0038\u0038\u0038"
Sorry.. I hit the wrong keys so it was sent too early. I would try something like this:
string oldString = "003800380038";
string newString = "";
while (oldString.Length >= 4) {
newString += ("\\u" + oldString.Substring(0,4));
oldString = oldString.Substring(4);
}
string oldString = "003800380038";
string newString = "";
while (oldString.Length >= 4) {
newString += ("\\u" + oldString.Substring(0,4));
oldString = oldString.Substring(4);
}
ASKER
Sorry I have been too vague.
The problem is not adding the escape char. The problem is getting the string converted to "8888". If I would output newString it would just show "\u0038".
All Unicode (utf16) characters are represented by hexadecimal numbers from 0000 to FFFF (in my case).
The problem is not adding the escape char. The problem is getting the string converted to "8888". If I would output newString it would just show "\u0038".
All Unicode (utf16) characters are represented by hexadecimal numbers from 0000 to FFFF (in my case).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
string oldString = "003800380038";
string newString = "";
for (int i=0; i < oldString.Length;i++) .{
}