Convert an integer into a base k string.
321995
def base10_integer_to_basek_string(k, x):
    """"""
    if not (2 <= k <= max_k_labeled):
        raise ValueError("k must be in range [2, %d]: %s"
                         % (max_k_labeled, k))
    return ((x == 0) and numerals[0]) or \
        (base10_integer_to_basek_string(k, x // k).\
         lstrip(numerals[0]) + numerals[x % k])
313609
def _string_to_int(self, s):
        
        base = len(self.alphabet)
        return sum((self._letter_to_int(l) * base**lsb 
                    for lsb, l in enumerate(s)
                   ))
1255566
def encode_int(v):
    """"""
    if not is_numeric(v) or v < 0 or v >= TT256:
        raise Exception("Integer invalid or out of range: %r" % v)
    return int_to_big_endian(v)
953665
def encode(val, base, minlen=0):
    

    base, minlen = int(base), int(minlen)
    code_string = get_code_string(base)
    result = ""
    while val > 0:
        result = code_string[val % base] + result
        val //= base
    return code_string[0] * max(minlen - len(result), 0) + result
463052
def from_bin(cls, value):
        """"""
        value = value.lstrip('b')
        if len(value) == 32:
            return cls(int(value, 2))
        elif len(value) == 128:
            return cls(int(value, 2))
        else:
            return ValueError('%r: invalid binary notation' % (value,))
37909
def parse_general_int(s):
    """"""
    mo = re.match(r"(\d+)([KkMGT]?)$", s)
    if mo:
        i, suffix = mo.group(1, 2)
        v = int(i)
        if suffix:
            if suffix == "K" or suffix == "k":
                v *= 1024
            elif suffix == "M":
                v *= (1024 * 1024)
            elif suffix == "G":
                v *= (1024 * 1024 * 1024)
            elif suffix == "T":
                v *= (1024 * 1024 * 1024 * 1024)
            else:
                raise ValueError("invalid integer string %s" % s)
        return v
    else:
        v = int(s)
    return v
24695
def base_to_int(s, base):
    
    
    digit = {}
    for i,c in enumerate(string.digits + string.ascii_uppercase):
        digit[c] = i
    multiplier = 1
    res = 0
    for c in s[::-1]:
        res += digit[c] * multiplier
        multiplier *= base
    return res
512027
function (token, k) {
        var str = "";
        for (var i = 0; i < k && i < token.length; i++)
            str += token[i];
        if (i < token.length) {
            str += "<";
            str += token[i++];
            str += ">";
            for (; i < token.length; i++)
                str += token[i];
        }
        return str;
    }
581101
private int coding(final String unit) throws KNXFormatException
	{
		expUnitAdjustment = 0;
		// @formatter:off
		switch (unit) {
		case "Wh": return 0b00000000;
		case "MWh": expUnitAdjustment = 6; return 0b10000000;
		case "kJ": expUnitAdjustment = 3; return 0b00001000;
		case "GJ": expUnitAdjustment = 9; return 0b10001000;
		case "l": expUnitAdjustment = -3; return 0b00010000;
		case "kg": return 0b00011000;
		case "W": return 0b00101000;
		case "MW": expUnitAdjustment = 6; return 0b10101000;
		case "kJ/h": expUnitAdjustment = 3; return 0b00110000;
		case "GJ/h": expUnitAdjustment = 9; return 0b10110000;
		case "l/h": expUnitAdjustment = -3; return 0b00111000;
		case "l/min": expUnitAdjustment = -3; return 0b01000000;
		case "ml/s": expUnitAdjustment = -6; return 0b01001000;
		case "kg/h": return 0b01010000;
//		case "": return 0b01101110; // 'units for HCA', we will opt for 'dimensionless counter'
		case "": return dimensionlessCounter;
		default: throw newException("unsupported unit", unit);
		}
		// @formatter:on
	}
549872
def decode_int(v):
    """"""
    if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
        raise Exception("No leading zero bytes allowed for integers")
    return big_endian_to_int(v)
1227879
function multiplyInteger(x, k) {
      var temp,
        carry = 0,
        i = x.length;

      for (x = x.slice(); i--;) {
        temp = x[i] * k + carry;
        x[i] = temp % BASE | 0;
        carry = temp / BASE | 0;
      }

      if (carry) x.unshift(carry);

      return x;
    }
763040
def convert_kv(key, val, attr_type, attr={}, cdata=False):
    """"""
    LOG.info('Inside convert_kv(): key="%s", val="%s", type(val) is: "%s"' % (
        unicode_me(key), unicode_me(val), type(val).__name__)
    )

    key, attr = make_valid_xml_name(key, attr)

    if attr_type:
        attr['type'] = get_xml_type(val)
    attrstring = make_attrstring(attr)
    return '<%s%s>%s</%s>' % (
        key, attrstring, 
        wrap_cdata(val) if cdata == True else escape_xml(val),
        key
    )
1001477
def num(value):
    """"""
    if re_hex_num.match(value):
        return int(value, base=16)
    else:
        return int(value)
359328
def convert_id36_to_numeric_id(id36):
    """"""
    if not isinstance(id36, six.string_types) or id36.count("_") > 0:
        raise ValueError("must supply base36 string, not fullname (e.g. use "
                         "xxxxx, not t3_xxxxx)")
    return int(id36, 36)
730440
def int_to_key(value, base=BASE62):
    
    def key_sequence_generator(value, base):
        """
        Generator for producing sequence of characters of a key providing an
        integer value and a base of characters for encoding, such as Base62
        for instance.

        @param value: a positive integer.
        @param base: a sequence of characters that is used to encode the
               integer value.

        @return: the next character of the object's key encoded with the
                 specified base.
            """
        base_length = len(base)
        while True:
            yield base[value % base_length]
            if value < base_length:
                break
            value /= base_length

    return ''.join([ c for c in key_sequence_generator(value, base) ])
707540
def from_int(value):
        """"""
        if not isinstance(value, int):
            raise PyVLXException("value_has_to_be_int")
        if not Parameter.is_valid_int(value):
            raise PyVLXException("value_out_of_range")
        return bytes([value >> 8 & 255, value & 255])
239726
def decode_int(self, str):
        
        n = 0
        for c in str:
            n = n * self.BASE + self.ALPHABET_REVERSE[c]
        return n