-
-
Save anonymous/c59a113ce5da0913e1f9 to your computer and use it in GitHub Desktop.
// What's the output of this code, and how confident are you? | |
// What might affect the result? | |
class Test | |
{ | |
static void Main() | |
{ | |
string stringx = "a"; | |
string\u180ex = "b"; | |
System.Console.WriteLine(stringx); | |
} | |
} |
b, 100%.
It should be "b", because the Mongolian vowel separator is a combining character.
So I guess the file's encoding might affect the result?
You should get "b" in the output... I wonder if an Mongolian vowel separator is legal according to the specs though...
EDIT: After some digging: The Mvs is not in the Unicode class 'Zs' which is determined to be a white space according to the C# Language Spec (Grammer section 1.2), it is in the class 'Cf' which is the class described as 'Other, Format'... Since it is not a white space... it is removed.
To my eyes it doesn't look like it compiles!
I'm still trying to find a machine that's sufficiently out of date to make it print "a". That should be a bit of a hint :)
(But both outputs are potentially valid. Arguably, only "a" strictly complies with the C# 5 specification, I believe...)
Ah - made more progress. It should either compile with a result of "b", or it should not compile. The Mono compiler (at least the version I'm using) has a bug where even "string\u0020x" works, but that fails to compile with csc.exe.
a