if (by == '\\') {
state = StateBackslash;
continue;
}
if (charOff >= cend) {
throw new ConversionBufferFullException();
}
chars[charOff++] = (char)by;
count++;
continue;
}
case StateBackslash: {
if (by == 'u') {
state = StateU;
continue;
}
if (charOff+1 >= cend) {
throw new ConversionBufferFullException();
}
chars[charOff++] = '\\';
chars[charOff++] = (char)by;
count+=2;
state = StateNormal;
break;
}
case StateU: {
int digit = Character.digit((char)by, 16);
if (digit == -1) {
throw new MalformedInputException();
}
escapedChar = (char)(digit << 12);
state = StateFirst;
break;
}
case StateFirst: {
int digit = Character.digit((char)by, 16);
if (digit == -1) {
throw new MalformedInputException();
}
escapedChar |= digit << 8;
state = StateSecond;
break;
}
case StateSecond: {
int digit = Character.digit((char)by, 16);
if (digit == -1) {
throw new MalformedInputException();
}
escapedChar |= digit << 4;
state = StateThird;
break;
}
case StateThird: {
int digit = Character.digit((char)by, 16);
if (digit == -1) {
throw new MalformedInputException();
}
escapedChar |= digit << 0;
if (charOff >= cend) {
throw new ConversionBufferFullException();
}
chars[charOff++] = escapedChar;
count++;
state = StateNormal;