package org.whitehole.infra.types;

import org.whitehole.infra.io.LargeByteBuffer;


public class StringAsciiz {

	static public String read(LargeByteBuffer buffer, long offset) {
		final StringBuilder sb = new StringBuilder();
		// Search for null termination
		while (buffer.get(offset) != 0) {
			sb.append((char) buffer.get(offset));
			++offset;
		}

		return sb.toString();
	}

	static public int byteSize(String s) {
		// Consider that s is an ASCII string, and add one for the terminating zero
		return 1 + s.length();
	}
}

@@ -391,24 +391,776 @@
 g();%0D%0A%09%7D%0D%0A%0D%0A
+%09static public String readLittleEndian(ByteArray8 x) %7B%0D%0A%09%09StringBuilder sb = new StringBuilder();%0D%0A%09%09if (x.getByte0() != 0) %7B%0D%0A%09%09%09sb.append((char) x.getByte0());%0D%0A%09%09%09if (x.getByte1() != 0) %7B%0D%0A%09%09%09%09sb.append((char) x.getByte1());%0D%0A%09%09%09%09if (x.getByte2() != 0) %7B%0D%0A%09%09%09%09%09sb.append((char) x.getByte2());%0D%0A%09%09%09%09%09if (x.getByte3() != 0) %7B%0D%0A%09%09%09%09%09%09sb.append((char) x.getByte3());%0D%0A%09%09%09%09%09%09if (x.getByte4() != 0) %7B%0D%0A%09%09%09%09%09%09%09sb.append((char) x.getByte4());%0D%0A%09%09%09%09%09%09%09if (x.getByte5() != 0) %7B%0D%0A%09%09%09%09%09%09%09%09sb.append((char) x.getByte5());%0D%0A%09%09%09%09%09%09%09%09if (x.getByte6() != 0) %7B%0D%0A%09%09%09%09%09%09%09%09%09sb.append((char) x.getByte6());%0D%0A%09%09%09%09%09%09%09%09%09if (x.getByte7() != 0)%0D%0A%09%09%09%09%09%09%09%09%09%09sb.append((char) x.getByte7());%0D%0A%09%09%09%09%09%09%09%09%7D%0D%0A%09%09%09%09%09%09%09%7D%0D%0A%09%09%09%09%09%09%7D%0D%0A%09%09%09%09%09%7D%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return sb.toString();%0D%0A%09%7D%0D%0A%0D%0A
 %09static publ

Read from ByteArray8, least-significant byte first.