Package java.nio.charset

Examples of java.nio.charset.CharsetDecoder.onUnmappableCharacter()


                        + actualName
                        + "\u201D, which is the declared encoding of this document.");
            }
            CharsetDecoder decoder = cs.newDecoder();
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
            this.reader = new InputStreamReader(stream, decoder);
        } catch (UnsupportedCharsetException e) {
            fatal("Unsupported character encoding \u201C" + actualName
                    + "\u201D.");
        }
View Full Code Here


    }

    public static void main(String[] args) {
        CharsetDecoder dec = Charset.forName("UTF-8").newDecoder();
        dec.onMalformedInput(CodingErrorAction.REPORT);
        dec.onUnmappableCharacter(CodingErrorAction.REPORT);
        byte[] bytes = { (byte) 0xF0, (byte) 0x9D, (byte) 0x80, (byte) 0x80 };
        byte[] bytes2 = { (byte) 0xB8, (byte) 0x80, 0x63, 0x64, 0x65 };
        ByteBuffer byteBuf = ByteBuffer.wrap(bytes);
        ByteBuffer byteBuf2 = ByteBuffer.wrap(bytes2);
        char[] chars = new char[1];
View Full Code Here

   {
      Charset cs = Charset.forName(sEncoding);
      CharsetDecoder decoder = cs.newDecoder();

      decoder.onMalformedInput(CodingErrorAction.REPLACE);
      decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);

      //Set up buffers
      byte[] bytes = new byte[nBufSize];
      ByteBuffer bytesIn = ByteBuffer.wrap(bytes);
      char[] chars = new char[nBufSize];
View Full Code Here

      //Get and configure decoder
      Charset cs = Charset.forName("utf-8");
      CharsetDecoder decoder = cs.newDecoder();
     
      decoder.onMalformedInput(CodingErrorAction.REPLACE);
      decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
     
      //Set up buffers
      ByteBuffer bytesIn = ByteBuffer.allocate(DECODE_BUFFER_SIZE);
      CharBuffer charsOut = CharBuffer.allocate(DECODE_BUFFER_SIZE);
      StringBuilder result = new StringBuilder(DECODE_BUFFER_SIZE);
View Full Code Here

        final CharsetDecoder decoder;
        try {
            mCharset = Charset.forName(aCharsetName);
            decoder = mCharset.newDecoder();
            decoder.onMalformedInput(CodingErrorAction.REPLACE);
            decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
        }
        catch (final UnsupportedCharsetException ex) {
            final String message = "Unsupported charset: " + aCharsetName;
            final UnsupportedEncodingException ex2;
            ex2 = new UnsupportedEncodingException(message);
View Full Code Here

            String encoding = stringArg(args, 1);
            IconvModuleImpl self = (IconvModuleImpl)thisObj;

            Charset cs = self.getCharset(cx, funObj, encoding);
            CharsetDecoder dec = cs.newDecoder();
            dec.onUnmappableCharacter(CodingErrorAction.REPLACE);
            CharBuffer decoded;
            try {
                decoded = dec.decode(buf.getBuffer());
            } catch (CharacterCodingException cce) {
                throw Utils.makeError(cx, funObj, cce.toString(), Constants.EINVAL);
View Full Code Here

        String s = constructString(SWISS_GERMAN_HELLO);
        byte[] tmp = s.getBytes("ISO-8859-1");

        CharsetDecoder decoder = Consts.UTF_8.newDecoder();
        decoder.onMalformedInput(CodingErrorAction.REPORT);
        decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, decoder, this.allocator);
        ReadableByteChannel channel = newChannel(tmp);
        while (inbuf.fill(channel) > 0) {
        }
        inbuf.readLine(true);
View Full Code Here

        String s = constructString(SWISS_GERMAN_HELLO);
        byte[] tmp = s.getBytes("ISO-8859-1");

        CharsetDecoder decoder = Consts.UTF_8.newDecoder();
        decoder.onMalformedInput(CodingErrorAction.IGNORE);
        decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, decoder, this.allocator);
        ReadableByteChannel channel = newChannel(tmp);
        while (inbuf.fill(channel) > 0) {
        }
        String result = inbuf.readLine(true);
View Full Code Here

        String s = constructString(SWISS_GERMAN_HELLO);
        byte[] tmp = s.getBytes("ISO-8859-1");

        CharsetDecoder decoder = Consts.UTF_8.newDecoder();
        decoder.onMalformedInput(CodingErrorAction.REPLACE);
        decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, decoder, this.allocator);
        ReadableByteChannel channel = newChannel(tmp);
        while (inbuf.fill(channel) > 0) {
        }
        String result = inbuf.readLine(true);
View Full Code Here

//    assertEquals("Assert 2: charset UTF16LE", 0, charbuf.length());
   
    // Regression for HARMONY-99
    CharsetDecoder decoder2 = Charset.forName("UTF-16").newDecoder();
    decoder2.onMalformedInput(CodingErrorAction.REPORT);
    decoder2.onUnmappableCharacter(CodingErrorAction.REPORT);
    ByteBuffer in = ByteBuffer.wrap(new byte[] { 109, 97, 109 });
    try {
      decoder2.decode(in);
      fail("Assert 3: MalformedInputException should have thrown");
    } catch (MalformedInputException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.