Created
December 6, 2010 09:20
-
-
Save renestein/730046 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 static class StringExtensions | |
{ | |
public static readonly string CHAR_UNICODE_FORMAT = "&#{0};"; | |
public static readonly int ASCII_INDEX = 127; | |
//Dirty fix for WP7 browser | |
public static string EncodeUnicodeChars(this string srcString) | |
{ | |
if (srcString == null) | |
{ | |
throw new ArgumentNullException("srcString"); | |
} | |
var resultString = srcString.Aggregate(new StringBuilder(), | |
(sb, ch) => | |
{ | |
var intCh = (int) ch; | |
if (intCh > ASCII_INDEX ) | |
{ | |
sb.AppendFormat(CHAR_UNICODE_FORMAT, intCh); | |
} | |
else | |
{ | |
sb.Append(ch); | |
} | |
return sb; | |
}, | |
sb => sb.ToString() | |
); | |
return resultString; | |
} | |
} |
Díky, opraveno. To je tak, když si dá člověk v půli refaktorizace panáka, aby přežil ty WP7 dary.:)
BTW: Diky za doporučení GISTů Aleši.
udělal jsem to hlavně kvůli sobě :)
A pak že sobectví není druh altruismu.;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pozor, intCh neni nikde použito, myslím, že by mělo být na následujících dvou řádcích...