5 |
|
|
6 |
public class Charset |
public class Charset |
7 |
{ |
{ |
8 |
static Charset forName(String name) |
public static Charset forName(String name) |
9 |
{ |
{ |
10 |
return new Charset(); |
return new Charset(); |
11 |
} |
} |
12 |
|
|
13 |
CharsetDecoder newDecoder() |
public CharsetDecoder newDecoder() |
14 |
{ |
{ |
15 |
return new CharsetDecoder(this,2,2) |
return new CharsetDecoder(this,2,2) |
16 |
{ |
{ |
27 |
}; |
}; |
28 |
} |
} |
29 |
|
|
30 |
CharsetEncoder newEncoder() |
public CharsetEncoder newEncoder() |
31 |
{ |
{ |
32 |
return new CharsetEncoder(this,2,2) |
return new CharsetEncoder(this,2,2) |
33 |
{ |
{ |
34 |
protected CoderResult encodeLoop(CharBuffer in, |
protected CoderResult encodeLoop(CharBuffer in, |
35 |
ByteBuffer out) |
ByteBuffer out) |
36 |
{ |
{ |
37 |
|
//System.out.println("in encode loop:"+in.hasRemaining()); |
38 |
|
|
39 |
while (in.hasRemaining()) |
while (in.hasRemaining()) |
40 |
{ |
{ |
41 |
char a = in.get(); |
char a = in.get(); |
42 |
out.put((byte)a); |
out.put((byte)a); |
43 |
|
|
44 |
//int len = out.position(); |
//int len = out.position(); |
45 |
//System.out.println("pos="+len); |
//System.out.println("pos="+len + ","+a); |
46 |
} |
} |
47 |
return null; |
return null; |
48 |
} |
} |