public static int readEscapedCharacter(PushbackReader r, boolean inClob)
        throws IOException, UnexpectedEofException
    {
        //    \\ The backslash character
        //    \0 The character 0 (nul terminator char, for some)
        //    \xhh The character with hexadecimal value 0xhh
        //    \ u hhhh The character with hexadecimal value 0xhhhh
        //    \t The tab character ('\u0009')
        //    \n The newline (line feed) character ('\ u 000A')
        //    \v The vertical tab character ('\u000B')
        //    \r The carriage-return character ('\ u 000D')
        //    \f The form-feed character ('\ u 000C')
        //    \a The alert (bell) character ('\ u 0007')
        //    \" The double quote character
        //    \' The single quote character
        //    \? The question mark character

        int c2 = 0, c = r.read();
        switch (c) {
            case -1:
                throw new UnexpectedEofException();
            case 't':  return '\t';
            case 'n':  return '\n';
            case 'v':  return '\u000B';
            case 'r':  return '\r';
            case 'f':  return '\f';
            case 'b':  return '\u0008';
            case 'a':  return '\u0007';
            case '\\': return '\\';
            case '\"': return '\"';
            case '\'': return '\'';
            case '/':  return '/';
            case '?':  return '?';

            case 'U':
                // Expecting 8 hex digits
                if (inClob) {
                    throw new IonException("Unicode escapes \\U not allowed in clob");
                }
                c = readDigit(r, 16, true);
                if (c < 0) break;  // TODO throw UnexpectedEofException
                c2 = c << 28;
                c = readDigit(r, 16, true);
                if (c < 0) break;
                c2 += c << 24;
                c = readDigit(r, 16, true);
                if (c < 0) break;
                c2 += c << 20;
                c = readDigit(r, 16, true);
                if (c < 0) break;
                c2 += c << 16;
                // ... fall through...
            case 'u':
                // Expecting 4 hex digits
                if (inClob) {
                    throw new IonException("Unicode escapes \\u not allowed in clob");
                }
                c = readDigit(r, 16, true);
                if (c < 0) break;
                c2 += c << 12;
                c = readDigit(r, 16, true);
                if (c < 0) break;
                c2 += c << 8;
                // ... fall through...
            case 'x':
                // Expecting 2 hex digits
                c = readDigit(r, 16, true);
                if (c < 0) break;
                c2 += c << 4;
                c = readDigit(r, 16, true);
                if (c < 0) break;
                return c2 + c;

            case '0':
                return 0;
            case '\n':
                return EMPTY_ESCAPE_SEQUENCE;
            default:
                break;
        }
        throw new IonException("invalid escape sequence \"\\"
                               + (char) c + "\" [" + c + "]");
    }
public static int readEscapedCharacter ( PushbackReader r , boolean inClob ) throws IOException , UnexpectedEofException { int c2 = 0 , c = r . read ( ) ; switch ( c ) { case - 1 : throw new UnexpectedEofException ( ) ; case 't' : return '\t' ; case 'n' : return '\n' ; case 'v' : return '' ; case 'r' : return '\r' ; case 'f' : return '\f' ; case 'b' : return '' ; case 'a' : return '' ; case '\\' : return '\\' ; case '\"' : return '\"' ; case '\'' : return '\'' ; case '/' : return '/' ; case '?' : return '?' ; case 'U' : if ( inClob ) { throw new IonException ( "Unicode escapes \\U not allowed in clob" ) ; } c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 = c << 28 ; c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 += c << 24 ; c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 += c << 20 ; c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 += c << 16 ; case 'u' : if ( inClob ) { throw new IonException ( "Unicode escapes \\u not allowed in clob" ) ; } c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 += c << 12 ; c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 += c << 8 ; case 'x' : c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; c2 += c << 4 ; c = readDigit ( r , 16 , true ) ; if ( c < 0 ) break ; return c2 + c ; case '0' : return 0 ; case '\n' : return EMPTY_ESCAPE_SEQUENCE ; default : break ; } throw new IonException ( "invalid escape sequence \"\\" + ( char ) c + "\" [" + c + "]" ) ; }
@return the translated escape sequence.  Will not return -1 since EOF is
not legal in this context. May return {@link #EMPTY_ESCAPE_SEQUENCE} to
indicate a zero-length sequence such as BS-NL.
@throws UnexpectedEofException if the EOF is encountered in the middle
of the escape sequence.