1

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 need 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.

ulrichb
  • 19,610
  • 8
  • 73
  • 87
Evan V.
  • 37
  • 1
  • 7

2 Answers2

1

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.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
1

call:

byte.Parse("12", NumberStyles.HexNumber);

on every to characters and store into byte[], then call Encoding.UTF8.GetString(byteStr)

Andrey
  • 59,039
  • 12
  • 119
  • 163
  • Thanks, that worked fine for £, carriage return and German! I still can't get Japanese or Greek characters to work, but I will worry about that later. Thanks again. – Evan V. Mar 16 '10 at 12:04