I'm trying to convert a string like
<Root>á</Root>
To it's UTF string representation, like this
<Root>á</Root>
(Taken from this page: http://www.cafewebmaster.com/online_tools/utf8_encode)
But when I issue Encoding.UTF8.GetBytes(str) I get an array of utf bytes.
How can I convert those bytes to the string representation I'm after?
--
Thanks for pointing that there is no string representation of an utf8 string.
Just to clarify my needs, I have to execute something like this in sql 2008:
xmlAuditoria_Alta
'
<Out>utf8 char: á</Out>
'
This is the only way I found so far to have this stored precedure correctly save the value
utf8 char: á
That's why I'm trying to convert from á to á
Perhaps there's a more correct way to do it
áis what happens when you incorrectly parse UTF8 bytes as a single-byte encoding. You should not do that.Encoding _1252 = new Encoding(1252); // or whatever single byte encoding you desire byte[] utf8 = Encoding.UTF8.GetBytes(str); string mangledStr = _1252.GetString(utf8);But I am positive that you do not ever want to do this!