Created
July 26, 2010 15:21
-
-
Save cstrahan/490693 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
// Languages\Ruby\Ruby\Builtins\RubyEncoding.cs | |
public static RubyEncoding/*!*/ GetRubyEncoding(Encoding/*!*/ encoding) { | |
ContractUtils.RequiresNotNull(encoding, "encoding"); | |
if (encoding == BinaryEncoding.Instance) { | |
return Binary; | |
} else if (encoding.ToString() == Encoding.UTF8.ToString()) { | |
return UTF8; | |
} else { | |
throw new ArgumentException(String.Format("Unknown encoding: '{0}'", encoding)); | |
} | |
} | |
/* | |
There's a tiny problem there when running IronRuby in Silverlight; it fails when the encoding is an instance of KCoding: | |
ArgumentException: Unknown encoding: 'KCODE (UTF8)' | |
*/ | |
//This... | |
} else if (encoding.ToString() == Encoding.UTF8.ToString()) { | |
// ... should be replaced with this: | |
} else if (encoding is KCoding || encoding == Encoding.UTF8) { | |
/* | |
The expression "Encoding.UTF8.ToString()" will always return "System.Encoding.UTF8", | |
so it doesn't make sense to test against that. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment