将16进制的String转化为Long，出错时返回默认值.
552975
public static Long hexToLongObject(@Nullable String str, Long defaultValue) {
		if (StringUtils.isEmpty(str)) {
			return defaultValue;
		}
		try {
			return Long.decode(str);
		} catch (final NumberFormatException nfe) {
			return defaultValue;
		}
	}
1262963
def _get_string(data, position, obj_end, dummy):
    """"""
    length = _UNPACK_INT(data[position:position + 4])[0]
    position += 4
    if length < 1 or obj_end - position < length:
        raise InvalidBSON("invalid string length")
    end = position + length - 1
    if data[end:end + 1] != b"\x00":
        raise InvalidBSON("invalid end of string")
    return _utf_8_decode(data[position:end], None, True)[0], end + 1
1263150
private boolean isLong(final String str) {
		try {
			Long.valueOf(str);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
489756
def _pad(self, data):
        
        length = 16 - (len(data) % 16)
        data += chr(length)*length
        return data
539266
def _decode16(self, offset):
        
        str_len, skip = self._decode_length(offset, 2)
        offset += skip

        # The len is the string len in utf-16 units
        encoded_bytes = str_len * 2

        data = self.m_charbuff[offset: offset + encoded_bytes]

        assert self.m_charbuff[offset + encoded_bytes:offset + encoded_bytes + 2] == b"\x00\x00", \
            "UTF-16 String is not null terminated! At offset={}".format(offset)

        return self._decode_bytes(data, 'utf-16', str_len)
793382
function (str, length, offset) {

                str = str || '';

                if (undefined === offset) {
                    offset = this.offset;
                }

                length  = length || str.replace(/[^\x00-\xff]/g, '11').length;

                if (length < 0 || offset + length > this.length) {
                    error.raise(10002, this.length, offset + length);
                }

                this.seek(offset);

                for (var i = 0, l = str.length, charCode; i < l; ++i) {
                    charCode = str.charCodeAt(i) || 0;
                    if (charCode > 127) {
                        // unicode编码可能会超出2字节,
                        // 写入与编码有关系，此处不做处理
                        this.writeUint16(charCode);
                    }
                    else {
                        this.writeUint8(charCode);
                    }
                }

                this.offset = offset + length;

                return this;
            }
479850
public static long getLong(
    Object      value)
  {
    if (value == null)
    {
        return 0;
    }

    return Long.valueOf(value.toString()).longValue();
  }
1082974
public Long toLong() {
		Long value;
		value = Long.valueOf(this.isNeg ? Long.parseLong(this.param)*-1 : Long.parseLong(this.param));
		return value;
	}
1368771
private String long2string(Long value, DateTimeFormat fmt) {
        // for html5 inputs, use "" for no value
        if (value == null) return "";
        Date date = UTCDateBox.utc2date(value);
        return date != null ? fmt.format(date) : null;
    }
478632
final void writeLong(long value)
    {
        byte writeBuffer[] = new byte[8];
        writeBuffer[0] = (byte) (value >>> 56);
        writeBuffer[1] = (byte) (value >>> 48);
        writeBuffer[2] = (byte) (value >>> 40);
        writeBuffer[3] = (byte) (value >>> 32);
        writeBuffer[4] = (byte) (value >>> 24);
        writeBuffer[5] = (byte) (value >>> 16);
        writeBuffer[6] = (byte) (value >>> 8);
        writeBuffer[7] = (byte) (value >>> 0);
        write(writeBuffer, 0, 8);
    }
1186740
function wstring(bits, s) {
      var charLength = bits / 8;
      var dataLength = s.length * charLength;
      var res = Buffer.alloc(xutil.padded_length(dataLength));
      debugger;
      var write = res[bufferWriteBits[bits]];
      res.fill(0);
      for (var i = 0; i < s.length; i++) write.call(res, s.charCodeAt(i), i * charLength);
      return res;
    }
1190735
def add_net16string(self, string):
		
		if len(string) >= (1 << 16):
			raise ValueError("string too long")
		return self.add_net16int(len(string)).add(string)
1197305
def _printed_len(some_string):
  """"""
  return len([x for  x in ANSI_ESC_RE.sub('', some_string)
              if x in string.printable])
775091
private static String getShortString(ByteBuffer buffer)
    {
        int len = buffer.get() & 0xff;

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < len; i++)
        {
            builder.append((char)(buffer.get() & 0xff));
        }
        String s = builder.toString();
        return s;
    }
1290685
static function dumpString(
        string $string,
        ?int $maxLength = null,
        ?string $encoding = null,
        ?array $quotes = null,
        ?string $ellipsis = null
    ): string {
        $stringLength = $encoding === null
            ? mb_strlen($string)
            : mb_strlen($string, $encoding);

        $tooLong = $maxLength !== null && $stringLength > $maxLength;

        return
            $quotes[0]
            . addcslashes(
                $tooLong
                    ? ($encoding === null
                    ? mb_substr($string, 0, $maxLength)
                    : mb_substr($string, 0, $maxLength, $encoding)
                )
                    : $string,
                "\000..\037"
            )
            . $quotes[1]
            . ($tooLong ? $ellipsis : '');
    }
897182
public static String long2String(long x)
    {
        char[] cArray = long2char(x);
        StringBuilder sbResult = new StringBuilder(cArray.length);
        for (char c : cArray)
        {
            sbResult.append(c);
        }
        return sbResult.toString();
    }
229513
private static BigInteger bigForString(String str, int sigchars)
    {
        assert str.length() <= sigchars;

        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }