开发者

Delphi 10, .NET, how do I convert a hex UTF-8 string to its unicode character?

开发者 https://www.devze.com 2022-12-22 20:03 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号