Skip to content

Instantly share code, notes, and snippets.

@testanull
Created August 31, 2021 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save testanull/e1a8a8f0d8488d89e5cf01b5559d3feb to your computer and use it in GitHub Desktop.
Save testanull/e1a8a8f0d8488d89e5cf01b5559d3feb to your computer and use it in GitHub Desktop.
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