Home | History | Annotate | Download | only in charset

Lines Matching refs:offset

63      * Encode {@code s} into {@code dst} starting at offset {@code offset}.
67 public static void encode(byte[] dst, int offset, String s) {
73 dst[offset++] = (byte) 0xc0;
74 dst[offset++] = (byte) 0x80;
76 dst[offset++] = (byte) c;
79 dst[offset++] = (byte) ((c >>> 6) | 0xc0);
80 dst[offset++] = (byte) ((c & 0x3f) | 0x80);
82 dst[offset++] = (byte) ((c >>> 12) | 0xe0);
83 dst[offset++] = (byte) (((c >>> 6) & 0x3f) | 0x80);
84 dst[offset++] = (byte) ((c & 0x3f) | 0x80);
109 * Decodes {@code length} utf-8 bytes from {@code in} starting at offset {@code offset} to
112 * <p>A maximum of {@code length} chars are written to the output starting at offset 0.
118 public static String decode(byte[] in, char[] out, int offset, int length)
120 if (offset < 0 || length < 0) {
121 throw new IllegalArgumentException("Illegal arguments: offset " + offset
125 int limitIndex = offset + length;
126 while (offset < limitIndex) {
127 int i = in[offset] & 0xff;
128 offset++;
139 if(offset == limitIndex) {
143 if ((in[offset] & 0xc0) != 0x80) {
144 throw new UTFDataFormatException("bad second byte at " + offset);
146 out[outputIndex] = (char) (i | (in[offset] & 0x3f));
147 offset++;
154 if (offset + 1 >= limitIndex) {
159 if ((in[offset] & 0xc0) != 0x80) {
160 throw new UTFDataFormatException("bad second byte at " + offset);
162 i = i | (in[offset] & 0x3f) << 6;
163 offset++;
165 if ((in[offset] & 0xc0) != 0x80) {
166 throw new UTFDataFormatException("bad third byte at " + offset);
168 out[outputIndex] = (char) (i | (in[offset] & 0x3f));
169 offset++;
173 + (int) i + " at position " + (offset - 1));