Return a iter consisting of two byte chars from a string.
421006
def str_to_two_byte_iter(string):
    
    bstring = string.encode()
    bytes = bytearray()
    for char in bstring:
        bytes.append(char)
        bytes.append(0)
    return bytes
918885
def read_string(buff, byteorder='big'):
    """"""
    length = read_numeric(USHORT, buff, byteorder)
    return buff.read(length).decode('utf-8')
565508
def cast_bytes(s, encoding='utf8', errors='strict'):
    """"""
    if isinstance(s, bytes):
        return s
    elif isinstance(s, str):
        return s.encode(encoding, errors)
    else:
        raise TypeError("Expected unicode or bytes, got %r" % s)
701853
public static FastStr of(Iterator<Character> itr) {
        StringBuilder sb = new StringBuilder();
        while (itr.hasNext()) {
            sb.append(itr.next());
        }
        return of(sb);
    }
379174
def _transpose(cls, char):
        """"""
        try:
            loc = ord(char) - 65
            if loc < 0 or loc > 56:
                return char
            return cls.UNICODE_MAP[loc]
        except UnicodeDecodeError:
            return char
724973
def bytes_to_string(raw):
    """"""
    ret = bytes()
    for byte in raw:
        if byte == 0x00:
            return ret.decode("utf-8")
        ret += bytes([byte])
    return ret.decode("utf-8")
638177
def iter_data(self):
        """"""
        for (k, v) in self.proxy.items():
            if (
                not (isinstance(k, str) and k[0] == '_') and
                k not in (
                    'character',
                    'name',
                    'location'
                )
            ):
                yield k, v
928631
def strToBytes(value):
    '''
    
    '''
    kassert.is_of_types(value, (bytes, bytearray, six.string_types))
    if isinstance(value, six.string_types):
        return bytes(bytearray([ord(x) for x in value]))
    elif isinstance(value, bytearray):
        return bytes(value)
    return value
573762
def p_chars(self, p):
        """"""
        if len(p) == 1:
            p[0] = unicode()
        else:
            p[0] = p[1] + p[2]
171330
def str_(name):
  """"""
  if isinstance(name, bytes) and not isinstance(name, str):
    return name.decode('utf8')
  else:
    return name
625818
def from_string(cls, hash, **context):
        """"""
        salt, checksum = parse_mc2(hash, cls.ident, handler=cls)

        return cls(salt=salt, checksum=checksum)
369106
def byte_str(s="", encoding="utf-8", input_encoding="utf-8", errors="strict"):
    
    assert isinstance(s, basestring)
    if isinstance(s, unicode):
        return s.encode(encoding, errors)
    if s and encoding != input_encoding:
        return s.decode(input_encoding, errors).encode(encoding, errors)
    return s
706104
function fromBytes(input){
    var len = input.length;
    var output = '';

    for (var i = 0; i < len; i++)
      output += chars[input[i]];

    return output;
  }
755525
def byte2bit_string(data):
    
    if isinstance(data, basestring):
        assert len(data) == 1
        data = ord(data)

    bits = '{0:08b}'.format(data)
    bits = bits[::-1]
    return bits
671087
def string(self, name):
        """"""
        self._assert_is_string(name)
        frame = self._next_frame()
        try:
            val = frame.decode('utf-8')
            self.results.__dict__[name] = val
        except UnicodeError as err:
            raise MessageParserError("Message contained invalid Unicode characters") \
                from err
        return self
997901
private static byte[] hexStringToByteArray(String s)
	{
		byte[] b = new byte[s.length() / 2];
		for (int i = 0; i < b.length; i++)
		{
			int index = i * 2;
			int v = Integer.parseInt(s.substring(index, index + 2), 16);
			b[i] = (byte) v;
		}
		return b;
	}
521984
def get_string_from_data(self, offset, data):
        """"""
        
        # OC Patch
        b = None
        
        try:
            b = data[offset]
        except IndexError:
            return ''
        
        s = ''
        while ord(b):
            s += b
            offset += 1
            try:
                b = data[offset]
            except IndexError:
                break
        
        return s