Merge pull request #1664 from bhamiltoncx/csharp-error-message-unicode
Support Unicode values > U+FFFF in C# runtime error messages
This commit is contained in:
commit
f5bbcaab51
|
@ -564,16 +564,17 @@ outer_continue: ;
|
||||||
public virtual string GetErrorDisplay(string s)
|
public virtual string GetErrorDisplay(string s)
|
||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
foreach (char c in s.ToCharArray())
|
for (var i = 0; i < s.Length; ) {
|
||||||
{
|
var codePoint = Char.ConvertToUtf32(s, i);
|
||||||
buf.Append(GetErrorDisplay(c));
|
buf.Append(GetErrorDisplay(codePoint));
|
||||||
|
i += (codePoint > 0xFFFF) ? 2 : 1;
|
||||||
}
|
}
|
||||||
return buf.ToString();
|
return buf.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string GetErrorDisplay(int c)
|
public virtual string GetErrorDisplay(int c)
|
||||||
{
|
{
|
||||||
string s = ((char)c).ToString();
|
string s;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case TokenConstants.EOF:
|
case TokenConstants.EOF:
|
||||||
|
@ -599,6 +600,12 @@ outer_continue: ;
|
||||||
s = "\\r";
|
s = "\\r";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
s = Char.ConvertFromUtf32(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue