/* ==========================================================================
read string data
484961
function read_buff(buff, offset, n) {
		var i;
		for (i = 0; i < n && deflate_pos < deflate_data.length; i++) {
			buff[offset + i] = deflate_data[deflate_pos++] & 0xff;
		}
		return i;
	}
449678
String readString() throws IOException {
		StringBuilder sb = new StringBuilder(50);
		// first char must be ":
		char ch = reader.next();
		if (ch != '\"') {
			throw new JsonParseException("Expected \" but actual is: " + ch,
					reader.readed);
		}
		for (;;) {
			ch = reader.next();
			if (ch == '\\') {
				// escape: \" \\ \/ \b \f \n \r \t
				char ech = reader.next();
				switch (ech) {
				case '\"':
					sb.append('\"');
					break;
				case '\\':
					sb.append('\\');
					break;
				case '/':
					sb.append('/');
					break;
				case 'b':
					sb.append('\b');
					break;
				case 'f':
					sb.append('\f');
					break;
				case 'n':
					sb.append('\n');
					break;
				case 'r':
					sb.append('\r');
					break;
				case 't':
					sb.append('\t');
					break;
				case 'u':
					// read an unicode uXXXX:
					int u = 0;
					for (int i = 0; i < 4; i++) {
						char uch = reader.next();
						if (uch >= '0' && uch <= '9') {
							u = (u << 4) + (uch - '0');
						} else if (uch >= 'a' && uch <= 'f') {
							u = (u << 4) + (uch - 'a') + 10;
						} else if (uch >= 'A' && uch <= 'F') {
							u = (u << 4) + (uch - 'A') + 10;
						} else {
							throw new JsonParseException("Unexpected char: " + uch,
									reader.readed);
						}
					}
					sb.append((char) u);
					break;
				default:
					throw new JsonParseException("Unexpected char: " + ch,
							reader.readed);
				}
			} else if (ch == '\"') {
				// end of string:
				break;
			} else if (ch == '\r' || ch == '\n') {
				throw new JsonParseException("Unexpected char: " + ch,
						reader.readed);
			} else {
				sb.append(ch);
			}
		}
		return sb.toString();
	}
698522
private String readString(int strLen) {
        char[] chars = new char[strLen];

        for (int i = 0; i < strLen; i++) {
            short a = Buffers.readUByte(buffer);
            if ((a & 0x80) == 0) {
                // ascii char
                chars[i] = (char) a;
            } else if ((a & 0xe0) == 0xc0) {
                // read one more
                short b = Buffers.readUByte(buffer);
                chars[i] = (char) (((a & 0x1F) << 6) | (b & 0x3F));
            } else if ((a & 0xf0) == 0xe0) {
                short b = Buffers.readUByte(buffer);
                short c = Buffers.readUByte(buffer);
                chars[i] = (char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F));
            } else if ((a & 0xf0) == 0xf0) {
                //throw new UTFDataFormatException();

            } else {
                //throw new UTFDataFormatException();
            }
            if (chars[i] == 0) {
                // the end of string.
            }
        }

        return new String(chars);
    }
883814
def read_request_from_str(data, **params):
    
    method, uri = None, None
    headers = {}
    host = ''

    try:
        split_list = data.split('\n\n')
        headers_text = split_list[0]
        body = '\n\n'.join(split_list[1:])
    except:
        headers_text = data
        body = ''

    body = force_bytes(body)
    for k, v in params.items():
        body = body.replace(b'{%s}' % force_bytes(k), force_bytes(v))

    header_list = headers_text.split('\n')

    for i, line in enumerate(header_list):
        line = line.strip()
        if line.strip() == '':
            continue

        line = line.format(**params)
        if i == 0:
            # 至多3个
            split_line = line.strip().split(' ')
            method, uri, _ = split_line[0], ' '.join(split_line[1:-1]), split_line[-1]
        else:
            # 至多2个
            header, value = line.split(':', 1)
            header = header.strip()
            value = value.strip()
            headers[header] = value
            if header.lower() == 'host':
                host = value

    return headers, method, uri, host, body
321308
final String readString(int position, Charset encoding) {
        // Sanity check the string size int position. Note that the eventual
        // m_buffer.get() does check for underflow, getInt() does not.
        if (STRING_LEN_SIZE > m_buffer.limit() - position) {
            throw new RuntimeException(String.format(
                    "VoltTableRow::readString: Can't read string size as %d byte integer " +
                    "from buffer with %d bytes remaining.",
                    STRING_LEN_SIZE, m_buffer.limit() - position));
        }
        final int len = m_buffer.getInt(position);
        //System.out.println(len);

        // check for null string
        if (len == VoltTable.NULL_STRING_INDICATOR)
            return null;

        if (len < 0) {
            throw new RuntimeException("Invalid object length.");
        }

        // Sanity check the size against the remaining buffer size.
        if (position + STRING_LEN_SIZE + len > m_buffer.limit()) {
            throw new RuntimeException(String.format(
                    "VoltTableRow::readString: Can't read %d byte string " +
                    "from buffer with %d bytes remaining.",
                    len, m_buffer.limit() - position - STRING_LEN_SIZE));
        }

        // this is a bit slower than directly getting the array (see below)
        // but that caused bugs
        byte[] stringData = new byte[len];
        int oldPos = m_buffer.position();
        m_buffer.position(position + STRING_LEN_SIZE);
        m_buffer.get(stringData);
        m_buffer.position(oldPos);

        return new String(stringData, encoding);
    }
1181652
public static String readString(DataInput in) throws IOException {
        int length = in.readInt();
        if (length == -1)
            return null;
        byte[] buffer = new byte[length];
        in.readFully(buffer); // could/should use readFully(buffer,0,length)?
        return new String(buffer, "UTF-8");
    }
1266258
@Override
    public String readString() {
        log.trace("readString - amf3_mode: {}", amf3_mode);
        String string;
        // check current type to ensure reading the string as AMF3 is intended
        if (currentDataType == AMF3.TYPE_STRING || amf3_mode > 0) {
            int len = readInteger();
            log.debug("readString - length: {}", len);
            // get the length of the string (0x03 = 1, 0x05 = 2, 0x07 = 3 etc..)
            // 0x01 is special and it means "empty"
            if (len == 1) {
                // Empty string
                return "";
            }
            if ((len & 1) == 0) {
                //if the refs are empty an IndexOutOfBoundsEx will be thrown
                if (refStorage.stringReferences.isEmpty()) {
                    log.debug("String reference list is empty");
                }
                // Reference
                return refStorage.stringReferences.get(len >> 1);
            }
            len >>= 1;
            log.debug("readString - new length: {}", len);
            int limit = buf.limit();
            log.debug("readString - limit: {}", limit);
            final ByteBuffer strBuf = buf.buf();
            strBuf.limit(strBuf.position() + len);
            string = AMF.CHARSET.decode(strBuf).toString();
            log.debug("String: {}", string);
            buf.limit(limit); // reset the limit
            refStorage.stringReferences.add(string);
        } else {
            // read the string as AMF0
            string = super.readString();
        }
        return string;
    }
362225
String parseString() throws IOException {
        buf.setLength(0);
        char next = readNext();
        while (next != '"') {
            if (next == '\\') {
                parseEscape();
            } else {
                buf.append(next);
            }
            next = readNext();
        }
        return buf.toString();
    }
968759
def get_string_from_data(self, offset, data):
        """"""
        s = self.get_bytes_from_data(offset, data)
        end = s.find(b'\0')
        if end >= 0:
            s = s[:end]
        return s
100775
public static int readLen(byte[] data) {
        if (data.length < Datagram.HEADER_LEN) {
            log.warn("要读取长度的数据报报头不完整");
            return -1;
        } else {
            return convert(data, Datagram.LEN_OFFSET);
        }
    }
400498
public void readData(DataInput din) throws IOException {
        // skip all following bytes
        int length = getDataLength();
        for (int i = 0; i < length; i++) {
            din.readByte();
        }
    }
1074091
static String readString(final DataInput in) throws IOException {
		final byte[] bytes = new byte[readInt(in)];
		in.readFully(bytes);
		return new String(bytes, "UTF-8");
	}
153641
function(str) {
			var data = [];
			
			str = str.toString();
			
			for(var x = 0;x < str.length; x++) {
				if(str[x].match(/^\d*$/g)) {
					data.push(str[x]);	
				}
			}
			
			return data;
		}
326664
function fixdata(data) {
		var o = '',
			l = 0,
			w = 10240;
		for (; l < data.byteLength / w; ++l)
			o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
		o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
		return o;
	}
919404
@Override
	public String readString() {
		int limit = buf.limit();
		int len = 0;
		switch (currentDataType) {
		case AMF.TYPE_LONG_STRING:
			log.trace("Long string type");
			len = buf.getInt();
			if (len > limit) {
				len = limit;
			}
			break;
		case AMF.TYPE_STRING:
			log.trace("Std string type");
			len = buf.getUnsignedShort();
			break;
		default:
			log.debug("Unknown AMF type: {}", currentDataType);
		}
		log.debug("Length: {} limit: {}", len, limit);
		byte[] str = new byte[len];
		buf.get(str);
		String string = bufferToString(str);
		return string;
	}
794698
function decode(string) {

        var stack = [], i = -1, decoded,
            type, top, value,
            getKey = false, key, isObj;

        bitsLeft = 8;
        streamIndex = 0;
        bitStream = string;
        bitValue = bitStream.charCodeAt(streamIndex);

        while(true) {

            // Grab type
            type = read(3);

            switch(type) {

            // Bool
            case 0:
                value = read(1) ? true : false;
                break;

            // EOS / Stream Overrun / Null
            case 7:
                switch(read(1)) {
                    case 1:
                        return decoded;

                    case 7:
                        return undefined;

                    default:
                        value = null;
                }
                break;

            // Integer / Float
            case 1:
            case 2:
                switch(read(3)) {
                    case 0:
                        value = read(1);
                        break;

                    case 1:
                        value = read(4);
                        break;

                    case 2:
                        value = read(8);
                        break;

                    case 3:
                        value = (read(4) << 8)
                                + read(8);

                        break;

                    case 4:
                        value = (read(8) << 8)
                                + read(8);

                        break;

                    case 5:
                        value = (read(4) << 16)
                                + (read(8) << 8)
                                + read(8);

                        break;

                    case 6:
                        value = (read(8) << 16)
                                + (read(8) << 8)
                                + read(8);

                        break;

                    case 7:
                        value = (read(8) << 24)
                                + (read(8) << 16)
                                + (read(8) << 8)
                                + read(8);

                        break;
                }

                if (read(1)) {
                    value = -value;
                }

                if (type === 2) {
                    value /= reversePowTable[read(4)];
                }

                break;

            // String
            case 3:

                var size = read(5);
                switch(size) {
                    case 31:
                        size = (read(8) << 24)
                               + (read(8) << 16)
                               + (read(8) << 8)
                               + read(8);

                        break;

                    case 30:
                        size = (read(8) << 8)
                               + read(8);

                        break;

                    case 29:
                        size = read(8);
                        break;

                }

                // Read a raw string from the stream
                if (bitsLeft !== 8) {
                    streamIndex++;
                    bitValue = 0;
                    bitsLeft = 8;
                }

                value = bitStream.substr(streamIndex, size);
                streamIndex += size;
                bitValue = bitStream.charCodeAt(streamIndex);

                if (getKey) {
                    key = value;
                    getKey = false;
                    continue;
                }

                break;

            // Open Array / Objects
            case 4:
            case 5:
                getKey = type === 5;
                value = getKey ? {} : [];

                if (decoded === undefined) {
                    decoded = value;

                } else {

                    if (isObj) {
                        top[key] = value;

                    } else {
                        top.push(value);
                    }
                }

                top = stack[++i] = value;
                isObj = !(top instanceof Array);
                continue;

            // Close Array / Object
            case 6:
                top = stack[--i];
                getKey = isObj = !(top instanceof Array);
                continue;
            }

            // Assign value to top of stack or return value
            if (isObj) {
                top[key] = value;
                getKey = true;

            } else if (top !== undefined) {
                top.push(value);

            } else {
                return value;
            }

        }

    }
59972
def read_string(data, length_fmt="H"):
    
    (length,), data = read(data, ">{0}".format(length_fmt))
    ba, data = data[:length], data[length:]
    return to_unicode(ba), data