-
-
Save rarous/671093 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public const string CharUnicodeFormat = "&#{0};"; | |
public static string EncodeUnicodeChars(this string text) { | |
if (text == null) { | |
throw new ArgumentNullException("text"); | |
} | |
return text.Aggregate( | |
new StringBuilder(), | |
(sb, ch) => sb.AppendFormat(CharUnicodeFormat, (int)ch), | |
sb => sb.ToString() | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment