1212
1313public class Charsetfunctions {
1414
15+ /**
16+ * Private constructor for real static class
17+ */
18+ private Charsetfunctions () {
19+
20+ }
21+
1522 public static CodingErrorAction codingErrorAction = CodingErrorAction .REPORT ;
1623
1724 /*
@@ -52,20 +59,6 @@ public static String stringUtf8( byte[] bytes ) throws InvalidDataException {
5259 return stringUtf8 ( ByteBuffer .wrap ( bytes ) );
5360 }
5461
55- /*public static String stringUtf8( byte[] bytes, int off, int length ) throws InvalidDataException {
56- CharsetDecoder decode = Charset.forName( "UTF8" ).newDecoder();
57- decode.onMalformedInput( codingErrorAction );
58- decode.onUnmappableCharacter( codingErrorAction );
59- //decode.replaceWith( "X" );
60- String s;
61- try {
62- s = decode.decode( ByteBuffer.wrap( bytes, off, length ) ).toString();
63- } catch ( CharacterCodingException e ) {
64- throw new InvalidDataException( CloseFrame.NO_UTF8, e );
65- }
66- return s;
67- }*/
68-
6962 public static String stringUtf8 ( ByteBuffer bytes ) throws InvalidDataException {
7063 CharsetDecoder decode = Charset .forName ( "UTF8" ).newDecoder ();
7164 decode .onMalformedInput ( codingErrorAction );
@@ -82,11 +75,6 @@ public static String stringUtf8( ByteBuffer bytes ) throws InvalidDataException
8275 return s ;
8376 }
8477
85- public static void main ( String [] args ) throws InvalidDataException {
86- stringUtf8 ( utf8Bytes ( "\0 " ) );
87- stringAscii ( asciiBytes ( "\0 " ) );
88- }
89-
9078 /**
9179 * Implementation of the "Flexible and Economical UTF-8 Decoder" algorithm
9280 * by Björn Höhrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)
0 commit comments