Merge pull request #1643 from bhamiltoncx/fix-csharp-code-point-input-stream

Easy: Fix C# CodePointCharStream to actually work with code points > U+FFFF
This commit is contained in:
Terence Parr 2017-02-13 15:18:27 -08:00 committed by GitHub
commit fb805a589b
1 changed files with 2 additions and 1 deletions

View File

@ -302,12 +302,13 @@ namespace Antlr4.Runtime
{
this.data = new int[input.Length];
int dataIdx = 0;
for (int i = 0; i < input.Length; i++) {
for (int i = 0; i < input.Length; ) {
var codePoint = Char.ConvertToUtf32(input, i);
data[dataIdx++] = codePoint;
if (dataIdx > data.Length) {
Array.Resize(ref data, data.Length * 2);
}
i += codePoint <= 0xFFFF ? 1 : 2;
}
this.n = dataIdx;
}