Ever wanted to convert a string from UTF-8 to ASCII in order to use it in a text file or to post it on another on another website? Below you will find a static function that you can use from anyware in your Visual Studio solution to convert a string from UTF-8 to ASCII. It takes as a parameter the UTF-8 string and return the same string in ASCII.
public static string UTF8toASCII(string text) { System.Text.Encoding utf8 = System.Text.Encoding.UTF8; Byte[] encodedBytes = utf8.GetBytes(text); Byte[] convertedBytes = Encoding.Convert(Encoding.UTF8, Encoding.ASCII, encodedBytes); System.Text.Encoding ascii = System.Text.Encoding.ASCII; return ascii.GetString(convertedBytes); }
thanks a lot, i was looking for some thing like this.
all of latin america and europe likes this post
I need to find out what encoding a string is using…
Do you know how to do that???
Amazing! Its in fact awesome paragraph, I have got much clear idea regarding from this post.