Created
August 31, 2021 09:50
-
-
Save testanull/e1a8a8f0d8488d89e5cf01b5559d3feb to your computer and use it in GitHub Desktop.
This file contains 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
public class JavaCharStream | |
{ | |
public char readChar() throws java.io.IOException | |
{ | |
//truncated | |
if ((buffer[bufpos] = c = ReadByte()) != '\\') | |
{ | |
UpdateLineColumn(c); | |
// found a non-backslash char. | |
if ((c == 'u') && ((backSlashCnt & 1) == 1)) | |
{ | |
if (--bufpos < 0) | |
bufpos = bufsize - 1; | |
break; | |
} | |
//truncated | |
// Here, we have seen an odd number of backslash's followed by a 'u' | |
try | |
{ | |
while ((c = ReadByte()) == 'u') | |
++column; | |
buffer[bufpos] = c = (char)(hexval(c) << 12 | | |
hexval(ReadByte()) << 8 | | |
hexval(ReadByte()) << 4 | | |
hexval(ReadByte())); | |
column += 4; | |
} | |
//truncated | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment