Created
January 17, 2014 14:47
-
-
Save blairconrad/8474567 to your computer and use it in GitHub Desktop.
Fun with encodings!
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
> var defaultEncoding = Encoding.Default; | |
> var myEncoding = Encoding.GetEncoding(defaultEncoding.CodePage, new EncoderReplacementFallback("?"), new DecoderReplacementFallback("?")); | |
> (int)(defaultEncoding.GetBytes("\u042E")[0]) // \u042E is "Ю" - Yu (Cyrillic) | |
63 // "?" | |
> (int)(myEncoding.GetBytes("\u042E")[0]) | |
63 | |
> (int)(defaultEncoding.GetBytes("\u99AC")[0]) // \u99AC is "馬" - Horse | |
63 | |
> (int)(myEncoding.GetBytes("\u99AC")[0]) | |
63 | |
> (int)(defaultEncoding.GetBytes("\u03C0")[0]) // \u03C0 is "π" - pi (Greek) | |
112 // "p" - this is what we want to avoid, I think. | |
> (int)(myEncoding.GetBytes("\u03C0")[0]) | |
63 // "?" - this is better |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment