by
6,236 16
0
7
559k
64
Top 1% !
Popular
Famous
Pearl of Wisdom
Tagged
Specified
OpenSource
Popularity: 1123rd place

Published on:

InputName0s
InputType0String
LanguageCSharp
LicenseMIT_X11
MethodNameConvertUnicodeToAnsi
OSWindows
OutputTypestring

Converts Unicode string to Ansi String

Converts Unicode string to Ansi String
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/11297/Converts-Unicode-string-to-Ansi-String?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static string ConvertUnicodeToAnsi(String s) { /// <summary> /// Description: Converts Unicode string to Ansi String /// /// </summary> /// <exception cref="ArgumentNullException"></code></exception> /// <exception cref="EncoderExceptionFallback"></exception> /// <exception cref="DecoderExceptionFallback"></exception> /// <exception cref="ArgumentException"></exception> try { byte[] unicodeBytes = Encoding.Unicode.GetBytes(s); byte[] ansiBytes = Encoding.Convert(Encoding.Unicode, Encoding.Default, unicodeBytes); return Encoding.Default.GetString(ansiBytes).ToString(); } catch { throw; } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus