Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1217

Convert String (UTF-16) to UTF-8 in C#

$
0
0

I need to convert a string to UTF-8 in C#. I've already try many ways but none works as I wanted.I converted my string into a byte array and then to try to write it to an XML file (which encoding is UTF-8....) but either I got the same string (not encoded at all) either I got a list of byte which is useless....Does someone face the same issue ?

Edit :This is some of the code I used :

str= "testé";byte[] utf8Bytes = Encoding.UTF8.GetBytes(str);return Encoding.UTF8.GetString(utf8Bytes);

The result is "testé" or I expected something like "testé"...


Viewing all articles
Browse latest Browse all 1217

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>