Delphi 10, .NET, how do I convert a hex UTF-8 string to its unicode character?
I am trying to make my web app compatible with international languages and I am stuck with trying to convert escaped characters in my Delphi .NET DLL.
The front end code is passing the UTF-8 hex notation with an escape character e.g for お I pass \uE3818A. In my DLL I capture this and constract the following string '$E3818A'. I nee开发者_JS百科d to convert this back to お and send it to my database, I've been trying to use Encoding.UTF8.GetBytes and Encoding.UTF8.GetString but with no luck.
Anyone could help me figure this out?
Thank you.
call:
byte.Parse("12", NumberStyles.HexNumber);
on every to characters and store into byte[]
, then call Encoding.UTF8.GetString(byteStr)
Turn your string into a byte array representing the original bytes (in this case 0xE3, 0x81, 0x8A), and then call Encoding.UTF8.GetString(bytes)
- that should be fine.
精彩评论