Unicode SMP support for C# runtime error messages

This commit is contained in:
Ben Hamilton 2017-02-16 09:22:13 -08:00
parent 877f6a396b
commit f88e0cbfe0
1 changed files with 11 additions and 4 deletions

View File

@ -564,16 +564,17 @@ outer_continue: ;
public virtual string GetErrorDisplay(string s)
{
StringBuilder buf = new StringBuilder();
foreach (char c in s.ToCharArray())
{
buf.Append(GetErrorDisplay(c));
for (var i = 0; i < s.Length; ) {
var codePoint = Char.ConvertToUtf32(s, i);
buf.Append(GetErrorDisplay(codePoint));
i += (codePoint > 0xFFFF) ? 2 : 1;
}
return buf.ToString();
}
public virtual string GetErrorDisplay(int c)
{
string s = ((char)c).ToString();
string s;
switch (c)
{
case TokenConstants.EOF:
@ -599,6 +600,12 @@ outer_continue: ;
s = "\\r";
break;
}
default:
{
s = Char.ConvertFromUtf32(c);
break;
}
}
return s;
}