hive/html/js/basic.js
// parse a string containing C escape sequences
parse a string containing C escape sequences
parse a string containing C escape sequences
function parseCString(s)
{
    s = "" + s;
    return s.replace(/\\([\\abfnrtv'"?]|[0-8]{3}|x[0-9a-fA-F]{2})/g, function(match, submatch, offset, string) {
        if (submatch == '\\') {
            return '\\';
        } else if (submatch == 'a') {
            return "\x07";
        } else if (submatch == 'b') {
            return "\b";
        } else if (submatch == 'f') {
            return "\f";
        } else if (submatch == 'n') {
            return "\n";
        } else if (submatch == 'r') {
            return "\r";
        } else if (submatch == 't') {
            return "\t";
        } else if (submatch == 'v') {
            return "\v";
        } else if (submatch.length == 1) {
            return submatch;
        } else if (submatch.length == 3 && submatch[0] != 'x') {
            return String.fromCharCode(64 * (submatch[0] - "0") + 8 * (submatch[1] - "0") + (submatch[2] - "0"));
        } else {
            return String.fromCharCode(parseHexByte(submatch.substring(1)));
        }
    });
}
function parseCString ( s ) { s = "" + s ; return s . replace ( / \\([\\abfnrtv'"?]|[0-8]{3}|x[0-9a-fA-F]{2}) / g , function ( match , submatch , offset , string ) { if ( submatch == '\\' ) { return '\\' ; } else if ( submatch == 'a' ) { return "\x07" ; } else if ( submatch == 'b' ) { return "\b" ; } else if ( submatch == 'f' ) { return "\f" ; } else if ( submatch == 'n' ) { return "\n" ; } else if ( submatch == 'r' ) { return "\r" ; } else if ( submatch == 't' ) { return "\t" ; } else if ( submatch == 'v' ) { return "\v" ; } else if ( submatch . length == 1 ) { return submatch ; } else if ( submatch . length == 3 && submatch [ 0 ] != 'x' ) { return String . fromCharCode ( 64 * ( submatch [ 0 ] - "0" ) + 8 * ( submatch [ 1 ] - "0" ) + ( submatch [ 2 ] - "0" ) ) ; } else { return String . fromCharCode ( parseHexByte ( submatch . substring ( 1 ) ) ) ; } } ) ; }
parse a string containing C escape sequences
parse a string containing C escape sequences
// octal byte // hex byte