/** * Reads a UTF-8 string. * * We don't know how long the UTF-8 string is, so we have to read one * byte at a time. We could make an educated guess based on the * utf16_size and seek back if we get it wrong, but seeking backward * may cause the underlying implementation to reload I/O buffers. */ String readString() throws IOException { int utf16len = readUnsignedLeb128(); byte inBuf[] = new byte[utf16len * 3]; // worst case int idx; for (idx = 0; idx < inBuf.length; idx++) { byte val = readByte(); if (val == 0) break; inBuf[idx] = val; } return new String(inBuf, 0, idx, "UTF-8"); }
/** * Reads a UTF-8 string. * * We don't know how long the UTF-8 string is, so we have to read one * byte at a time. We could make an educated guess based on the * utf16_size and seek back if we get it wrong, but seeking backward * may cause the underlying implementation to reload I/O buffers. */ String readString() throws IOException { int utf16len = readUnsignedLeb128(); byte inBuf[] = new byte[utf16len * 3]; // worst case int idx; for (idx = 0; idx < inBuf.length; idx++) { byte val = readByte(); if (val == 0) break; inBuf[idx] = val; } return new String(inBuf, 0, idx, "UTF-8"); }
/** * Reads a UTF-8 string. * * We don't know how long the UTF-8 string is, so we have to read one * byte at a time. We could make an educated guess based on the * utf16_size and seek back if we get it wrong, but seeking backward * may cause the underlying implementation to reload I/O buffers. */ String readString() throws IOException { int utf16len = readUnsignedLeb128(); byte inBuf[] = new byte[utf16len * 3]; // worst case int idx; for (idx = 0; idx < inBuf.length; idx++) { byte val = readByte(); if (val == 0) break; inBuf[idx] = val; } return new String(inBuf, 0, idx, "UTF-8"); }
/** * Reads a UTF-8 string. * * We don't know how long the UTF-8 string is, so we have to read one * byte at a time. We could make an educated guess based on the * utf16_size and seek back if we get it wrong, but seeking backward * may cause the underlying implementation to reload I/O buffers. */ String readString() throws IOException { int utf16len = readUnsignedLeb128(); byte inBuf[] = new byte[utf16len * 3]; // worst case int idx; for (idx = 0; idx < inBuf.length; idx++) { byte val = readByte(); if (val == 0) { break; } inBuf[idx] = val; } return new String(inBuf, 0, idx, "UTF-8"); }
/** * Reads a UTF-8 string. * * We don't know how long the UTF-8 string is, so we have to read one * byte at a time. We could make an educated guess based on the * utf16_size and seek back if we get it wrong, but seeking backward * may cause the underlying implementation to reload I/O buffers. */ String readString() throws IOException { int utf16len = readUnsignedLeb128(); byte inBuf[] = new byte[utf16len * 3]; // worst case int idx; for (idx = 0; idx < inBuf.length; idx++) { byte val = readByte(); if (val == 0) break; inBuf[idx] = val; } return new String(inBuf, 0, idx, "UTF-8"); }