I have a string in C# which could contain any set of Unicode characters and I want to convert it into a hex representation of the UTF8 encoding of that string with a space between each Unicode character, so for instance the string “$£€????” would be converted to an output string of “24 C2A3 E282AC F0908D88”. I can’t see how to do this, though. Because strings in C# are UTF16 I can’t just say foreach (char entry in myString) { ... }
because a Unicode glyph can be represented by either 1 or 2 char
s, as in the case for the latter 2 glyphs in my example above.
How could I achieve the desired output?