I solved the issue by splitting the hex code to 4 characters each in an array then I swap the code to have it as UTF16BE instead of UTF16LE and after that, I converted the code point to characters.
.....
string PointCode, words;
int length = 4;
int strLength = value.Length;
int strCount = (strLength + length - 1) / length;
string[] result = new string[strCount];
char[] charcters = new char[strCount];
for (int i = 0; i < strCount; ++i)
{
result[i] = value.Substring(i * length, Math.Min(length, strLength));
strLength -= length;
//Swap the bytes from UTF16 LE to UTF16 BE
if (result[i].Length == 4)
{
string PointCode1 = result[i].Substring(0, 2);
string PointCode2 = result[i].Substring(2, 2);
PointCode = PointCode2 + PointCode1;
charcters[i] = (char)Int16.Parse(PointCode, System.Globalization.NumberStyles.HexNumber);
}
else
{
PointCode = "00" + result[i];
charcters[i] = (char)Int16.Parse(PointCode, System.Globalization.NumberStyles.HexNumber);
}
}
words = (string.Join("", charcters));
return words;
BigEndianUnicode
, but in this case it's garbled. It should be006F006E006A00750065003B00200043006F006D006D0061
(corresponding toonjue; Comma
). The final00
could be the string termination.Stream
of any kind? Is it astring
representing Hex values? A decoded content of a base64String? Anything else? Without code, it's really difficult to suggest how to convert something when this something is undefined, both in origin and type.Hi how are you? Everything is good?
in Arabic (مرحبا كيف حالك؟كل شي جيد؟باي). But it contains a wrong char at the beginning. That's why I asked how are you receiving this output. If you post the code that gets that string, maybe I can fix it to return a correct value. If what you posted is the complete content you received. Maybe you cut it in the wrong place.