public static string GetANTLRCharLiteralForChar( int c )
{
if ( c < Label.MIN_CHAR_VALUE )
{
ErrorManager.InternalError( "invalid char value " + c );
return "'<INVALID>'";
}
if ( c < AntlrLiteralCharValueEscape.Length && AntlrLiteralCharValueEscape[c] != null )
{
return '\'' + AntlrLiteralCharValueEscape[c] + '\'';
}
if ( c <= 0x7f && !char.IsControl( (char)c ) )
{
if ( c == '\\' )
{
return "'\\\\'";
}
if ( c == '\'' )
{
return "'\\''";
}
return "'" + (char)c + "'";
}
// turn on the bit above max "\uFFFF" value so that we pad with zeros
// then only take last 4 digits
string hex = c.ToString( "X4" ); //Integer.toHexString( c | 0x10000 ).toUpperCase().substring( 1, 5 );
string unicodeStr = "'\\u" + hex + "'";
return unicodeStr;
}