Return a string made from a list of two byte chars.
326317
def two_byte_iter_to_str(bytes):
    
    bytes = list(bytes)
    chars = bytearray()
    while bytes:
        lsb = bytes.pop(0)
        try:
            msb = bytes.pop(0)
        except IndexError:
            msb = 0x00
        chars.append(from_two_bytes([lsb, msb]))
    return chars.decode()
911464
def byte_to_unitcode(bytecode):
    """"""
    return list(UC_LOOKUP.keys())[list(UC_LOOKUP.values()).index(bytecode)]
520044
def _get_c_string(data, position):
    """"""
    end = data.index(b"\x00", position)
    return _utf_8_decode(data[position:end], None, True)[0], end + 1
297080
def str_to_bytes(self, s):
        ""
        if (PYTHON_MAJOR_VER == 3 or
                (PYTHON_MAJOR_VER == 2 and type(s) == unicode)):
            return s.encode(charset_map.get(self.charset, self.charset))
        return s
947655
private static char[] chars(byte[] bytes) {
        char[] chars = new char[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            int pos = bytes[i] & 0xff;
            chars[i] = (char) pos;
        }
        return chars;
    }
25274
public static byte[] string2Bytes(String str) {
    try {
      final int len = str.length();
      // if we can, we will use it to return the bytes
      byte[] rawBytes = new byte[len];
      
      // get all chars of the given string
      char[] charArray = UTF8.getCharArray(len);
      str.getChars(0, len, charArray, 0);
      
      for (int i = 0; i < len; i++) {
        if (charArray[i] > UTF8.MAX_ASCII_CODE) {
          // non-ASCII chars present
          // do expensive conversion
          return str.getBytes(utf8charsetName);
        }
        // copy to output array
        rawBytes[i] = (byte) charArray[i];
      }
      // only ASCII present - return raw bytes
      return rawBytes;
    } catch (UnsupportedEncodingException e) {
      assert false : "UTF8 encoding is not supported ";
    }
    return null;
  }
838844
def decode_chain_list(in_bytes):
    """"""
    tot_strings = len(in_bytes) // mmtf.utils.constants.CHAIN_LEN
    out_strings = []
    for i in range(tot_strings):
        out_s = in_bytes[i * mmtf.utils.constants.CHAIN_LEN:i * mmtf.utils.constants.CHAIN_LEN + mmtf.utils.constants.CHAIN_LEN]
        out_strings.append(out_s.decode("ascii").strip(mmtf.utils.constants.NULL_BYTE))
    return out_strings
625488
def str_to_bitstring(data):
    """"""
    assert isinstance(data, bytes), "Data must be an instance of bytes"
    byte_list = data_to_byte_list(data)
    bit_list = [bit for data_byte in byte_list for bit in byte_to_bitstring(data_byte)]
    return bit_list
414046
def list2string (inlist,delimit=' '):
    
    stringlist = [makestr(_) for _ in inlist]
    return string.join(stringlist,delimit)
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)
955203
function (bytes) {
                var s = '';
                for (var i = 0, l = bytes.length; i < l; i++) {
                    s += String.fromCharCode(bytes[i]);
                }
                return s;
            }
645437
private static byte[] stringToByteArray(String str) {
		byte[] result = new byte[str.length() + 1];
		for (int i = 0; i < str.length(); i++) {
			result[i] = (byte) str.charAt(i);
		}
		result[str.length()] = 0;
		return result;
	}
658251
private static String byte2hex(byte[] bytes) {
        char[] hexChars =
                {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
                        'c', 'd', 'e', 'f'};

        StringBuffer sb = new StringBuffer();
        for (byte b : bytes) {
            sb.append(hexChars[b >> 4 & 0xf]);
            sb.append(hexChars[b & 0xf]);
        }

        return new String(sb);
    }
142204
function (bytes) {
                var str = '';
                for (var i = 0, l = bytes.length; i < l; i += 2) {
                    str += String.fromCharCode((bytes[i] << 8) + bytes[i + 1]);
                }
                return str;
            }
219348
def string_to_list(string, sep=",", filter_empty=False):
    """"""
    return [value.strip() for value in string.split(sep)
            if (not filter_empty or value)]
1003026
function (str) {
			for (var bytes = [], i = 0; i < str.length; i++)
				bytes.push(str.charCodeAt(i) & 0xFF);
			return bytes;
		}
593147
def to_bytes(s):
    '''
    '''
    if isinstance(s, six.binary_type):
        return s
    if isinstance(s, six.string_types):
        return s.encode('utf-8')
    raise TypeError('want string or bytes, got {}', type(s))