Pretty-print bytes 1-15; byte 0 is the udp_type enum
977276
@Override String print16( AutoBuffer ab ) {
    ab.getPort();
    return T.values()[ab.get1()].toString();
  }
425523
function(dec, bytes) {
    var hex = "",
        i;
    for (i = 0; i < bytes; i++) {
        hex += String.fromCharCode(dec & 0xff);
        dec = dec >>> 8;
    }
    return hex;
}
1347411
def pprnt(input, return_data=False):
    
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[32m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
    import json, re
    result = json.dumps(input, sort_keys=True, indent=4)
    result = re.sub(r'(")(\w*?_id)(":)', r'\1%s%s\2%s\3' % (BOLD, HEADER, ENDC), result)
    result = re.sub(r'(")(\w*?_set)(":)', r'\1%s%s\2%s\3' % (BOLD, HEADER, ENDC), result)
    result = re.sub(r'(\n *?")(\w*?)(":)', r'\1%s%s\2%s\3' % (BOLD, OKGREEN, ENDC), result)
    if not return_data:
        print(result)
    else:
        return result
843915
private boolean isDatatype( DdlTokenStream tokens,
                                int type ) throws ParsingException {
        // Loop through the registered statement start string arrays and look for exact matches.

        switch (type) {
            case DataTypes.DTYPE_CODE_CHAR_STRING: {
                for (String[] stmts : basicCharStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_NCHAR_STRING: {
                for (String[] stmts : basicNationalCharStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_BIT_STRING: {
                for (String[] stmts : basicBitStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_EXACT_NUMERIC: {
                for (String[] stmts : basicExactNumericTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_APROX_NUMERIC: {
                for (String[] stmts : basicApproxNumericStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_DATE_TIME: {
                for (String[] stmts : basicDateTimeTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_MISC: {
                for (String[] stmts : basicMiscTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
        }

        return false;
    }
260431
function UInt8(value, opt) {
	SingleType.call(this, value, 1, Buffer.prototype.readUInt8, Buffer.prototype.writeUInt8, opt);
}
51722
def prettyPrintDictionary(d):
    ''''''
    maxKeyLength = 0
    maxValueLength = 0
    for key, value in d.iteritems():
        maxKeyLength = max(maxKeyLength, len(key))
        maxValueLength = max(maxValueLength, len(key))
    for key in sorted(d.keys()):
        print ("%"+str(maxKeyLength)+"s : %-" + str(maxValueLength)+ "s") % (key,d[key])
1064223
public static function bytes_pretty_print($bytes)
    {
        if ($bytes < 1024) {
            return $bytes . " B";
        }

        $kbytes = $bytes / 1024;

        if ($kbytes < 1024) {
            return round($kbytes, 3) . " KB";
        }

        $mbytes = $kbytes / 1024;

        if ($mbytes < 1024) {
            return round($mbytes, 3) . " MB";
        }

        $tbytes = $mbytes / 1024;

        if ($tbytes < 1024) {
            return round($tbytes, 3) . " TB";
        }

        $gbytes = $tbytes / 1024;

        return round($gbytes, 3) . " GB";
    }
432093
def is_printable(c):
    ''''''
    global have_ascii
    if have_ascii:
        return ascii.isprint(c)
    if isinstance(c, int):
        ic = c
    else:
        ic = ord(c)
    return ic >= 32 and ic <= 126
899018
def enc_byte(self):
        """"""
        try:
            c = self.encdata[self.encpos]
            self.encpos += 1
            return c
        except IndexError:
            self.failed = 1
            return 0
1306231
function UInt16Be(value, opt) {
	SingleType.call(this, value, 2, Buffer.prototype.readUInt16BE, Buffer.prototype.writeUInt16BE, opt);
}
570630
function debugPrintFlatScannedData(data, printer) {
        var pInfo = [
            'numConnectionTypes',
            'connectionTypeNames',
            'verifiedConnectionTypeNames',
            'connectionTypes',
            'unverifiedConnectionTypeNames',
        ];

        if(DEBUG_MARKING_ACTIVE_CONNECTION_TYPES) {
            pInfo.push('handle');
            pInfo.push('dt');
            pInfo.push('deviceType');
            pInfo.push('deviceTypeStr');
            pInfo.push('deviceTypeString');
            pInfo.push('deviceTypeName');
            pInfo.push('handleConnectionType');
            pInfo.push('handleConnectionTypeStr');
            pInfo.push('handleConnectionTypeName');
            pInfo.push('ct');
            pInfo.push('connectionType');
            pInfo.push('connectionTypeStr');
            pInfo.push('connectionTypeName');
            pInfo.push('serialNumber');
            pInfo.push('ip');
            pInfo.push('port');
            pInfo.push('maxBytesPerMB');
            pInfo.push('maxBytesPerMB');
            pInfo.push('isActive');
        }
        var pData = {};
        var keys = Object.keys(data);
        keys.forEach(function(key) {
            var dData = data[key];
            var dKeys = Object.keys(dData);
            pData[key] = {};
            var otherKeys = [];
            // loop through each available device.
            dKeys.forEach(function(dKey) {
                // Save the requested key's info.
                if(pInfo.indexOf(dKey) >= 0) {
                    pData[key][dKey] = dData[dKey];
                } else {
                    otherKeys.push(dKey);
                }
            });
            // pData[key].keys = otherKeys;
        });
        if(printer) {
            printer('Scanned Data', pData);
        } else {
            console.log('Scanned Data', pData);
        }
    }
707710
function num2str(type) {
  switch (Number(type)) {
    case types.BYTE:
      return 'byte';
    case types.CHAR:
      return 'char';
    case types.SHORT:
      return 'short';
    case types.INT:
      return 'int';
    case types.FLOAT:
      return 'float';
    case types.DOUBLE:
      return 'double';
      /* istanbul ignore next */
    default:
      return 'undefined';
  }
}
682019
public static String bcdToStr(byte[] bytes) {
		char temp[] = new char[bytes.length * 2], val;

		for (int i = 0; i < bytes.length; i++) {
			val = (char) (((bytes[i] & 0xf0) >> 4) & 0x0f);
			temp[i * 2] = (char) (val > 9 ? val + 'A' - 10 : val + '0');

			val = (char) (bytes[i] & 0x0f);
			temp[i * 2 + 1] = (char) (val > 9 ? val + 'A' - 10 : val + '0');
		}
		return new String(temp);
	}
482682
def print_bytes(data):
    
    bs = bytearray(data)
    symbols_in_one_line = 8
    n = len(bs) // symbols_in_one_line
    i = 0
    for i in range(n):
        print(str(i*symbols_in_one_line)+" | "+" ".join(["%02X" % b for b in bs[i*symbols_in_one_line:(i+1)*symbols_in_one_line]])) # for every 8 symbols line
    if not len(bs) % symbols_in_one_line == 0:
        print(str((i+1)*symbols_in_one_line)+" | "+" ".join(["%02X" % b for b in bs[(i+1)*symbols_in_one_line:]])+"\n")
1190107
private static int readLen16(ByteBuffer buffer) {
        int len = 0;
        int i = Buffers.readUShort(buffer);
        if ((i & 0x8000) != 0) {
            len |= (i & 0x7fff) << 16;
            len += Buffers.readUShort(buffer);
        } else {
            len = i;
        }
        return len;
    }
988208
static function fromUtf8( $multi_char, $offs, &$len )
    {
        $char_code = false;
        if ( ( ord( $multi_char[$offs + 0] ) & 0x80 ) == 0x00 ) // 7 bit, 1 char
        {
            $char_code = ord( $multi_char[$offs + 0] );
            $len = 1;
        }
        else if ( ( ord( $multi_char[$offs + 0] ) & 0xe0 ) == 0xc0 ) // 11 bit, 2 chars
        {
            $len = 2;
            if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 )
                return $char_code;
            $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x1f ) << 6) +
                           (( ord( $multi_char[$offs + 1] ) & 0x3f )) );
            if ( $char_code < 128 ) // Illegal multibyte, should use less than 2 chars
            {
                $char_code = false;
            }
        }
        else if ( ( ord( $multi_char[$offs + 0] ) & 0xf0 ) == 0xe0 ) // 16 bit, 3 chars
        {
            $len = 3;
            if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 )
                return $char_code;
            $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x0f ) << 12) +
                           (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 6) +
                           (( ord( $multi_char[$offs + 2] ) & 0x3f )) );
            if ( $char_code < 2048 ) // Illegal multibyte, should use less than 3 chars
            {
                $char_code = false;
            }
        }
        else if ( ( ord( $multi_char[$offs + 0] ) & 0xf8 ) == 0xf0 ) // 21 bit, 4 chars
        {
            $len = 4;
            if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 3] ) & 0xc0 ) != 0x80 )
                return $char_code;
            $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x07 ) << 18) +
                           (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 12) +
                           (( ord( $multi_char[$offs + 2] ) & 0x3f ) << 6) +
                           (( ord( $multi_char[$offs + 3] ) & 0x3f )) );
            if ( $char_code < 65536 ) // Illegal multibyte, should use less than 4 chars
            {
                $char_code = false;
            }
        }
        else if ( ( ord( $multi_char[$offs + 0] ) & 0xfc ) == 0xf8 ) // 26 bit, 5 chars
        {
            $len = 5;
            if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 3] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 4] ) & 0xc0 ) != 0x80 )
                return $char_code;
            $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x03 ) << 24) +
                           (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 18) +
                           (( ord( $multi_char[$offs + 2] ) & 0x3f ) << 12) +
                           (( ord( $multi_char[$offs + 3] ) & 0x3f ) << 6) +
                           (( ord( $multi_char[$offs + 4] ) & 0x3f )) );
            if ( $char_code < 2097152 ) // Illegal multibyte, should use less than 5 chars
            {
                $char_code = false;
            }
        }
        else if ( ( ord( $multi_char[$offs + 0] ) & 0xfe ) == 0xfc ) // 31 bit, 6 chars
        {
            $len = 6;
            if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 3] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 4] ) & 0xc0 ) != 0x80 or
                 ( ord( $multi_char[$offs + 5] ) & 0xc0 ) != 0x80 )
                return $char_code;
            $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x01 ) << 30) +
                           (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 24) +
                           (( ord( $multi_char[$offs + 2] ) & 0x3f ) << 18) +
                           (( ord( $multi_char[$offs + 3] ) & 0x3f ) << 12) +
                           (( ord( $multi_char[$offs + 4] ) & 0x3f ) << 6) +
                           (( ord( $multi_char[$offs + 5] ) & 0x3f )) );
            if ( $char_code < 67108864 ) // Illegal multibyte, should use less than 6 chars
            {
                $char_code = false;
            }
        }
        return $char_code;
    }
249893
def display_value(bytes)
      return '-'   if bytes.nil?
      return '0 B' if bytes.zero?

      case [Math.log10(bytes.abs).floor, 0].max
      when  0...4  then '%d B'  % bytes
      when  4...7  then '%d kB' % (bytes / 1000)
      when  7...10 then '%d MB' % (bytes / 1_000_000)
      when 10...13 then '%d GB' % (bytes / 1_000_000_000)
      else              '%d TB' % (bytes / 1_000_000_000_000)
      end
    end