Sunday, March 24, 2019

c# - How to convert UTF-8 byte[] to string?



I have a byte[] array that is loaded from a file that I happen to known contains UTF-8. In some debugging code, I need to convert it to a string. Is there a one liner that will do this?



Under the covers it should be just an allocation and a memcopy, so even if it is not implemented, it should be possible.


Answer



string result = System.Text.Encoding.UTF8.GetString(byteArray);


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...