Package java.nio.charset

Examples of java.nio.charset.CharsetEncoder.reset()


        ByteBuffer bb = ByteBuffer.allocate(20);
        CharBuffer cb = CharBuffer.wrap(chararray);
       
        ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.OVERFLOW, CharsetCallback.FROM_U_CALLBACK_ESCAPE, null)// This callback is not valid.
        for (int i = 0; i < context1.length; i++) {
            encoder.reset();
            cb.position(0);
            bb.position(0);
            ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_ESCAPE, context1[i]); // This callback is valid.
           
            result = encoder.encode(cb, bb, true);
View Full Code Here


            }
        }
       
        // Testing encoder skip callback
        for (int i = 0; i < context3.length; i++) {
            encoder.reset();
            cb.position(0);
            bb.position(0);
            ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_SKIP, context3[i]);
           
            result = encoder.encode(cb, bb, true);
View Full Code Here

            }
        }
       
        // Testing encoder sub callback
        for (int i = 0; i < context3.length; i++) {
            encoder.reset();
            cb.position(0);
            bb.position(0);
            ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_SUBSTITUTE, context3[i]);
           
            result = encoder.encode(cb, bb, true);
View Full Code Here

                if (!cr.isMalformed() || cr.length() != 3) {
                    errln("Incorrect result in " + converter + " decoder for 0x"
                            + Integer.toHexString(i) + " received " + cr);
                    break;
                }
                encoder.reset();
                cr = encoder.encode(us, bs, true);
                bs.rewind();
                us.rewind();
                if (!cr.isMalformed() || cr.length() != 1) {
                    errln("Incorrect result in " + converter + " encoder for 0x"
View Full Code Here

        int testLoopSize = 5;
        int bbLimits[] = { 0, 1, 3, 4, 6};
        int bbPositions[] = { 0, 0, 0, 3, 3 };
        int ccPositions[] = { 0, 0, 0, 2, 2 };
        for (int i = 0; i < testLoopSize; i++) {
            encoder.reset();
            bb.limit(bbLimits[i]);
            bb.position(bbPositions[i]);
            cb.position(ccPositions[i]);
            result = encoder.encode(cb, bb, true);
           
View Full Code Here

            ByteBuffer expected = null;
            try {
                encoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
                encoder.onMalformedInput(CodingErrorAction.IGNORE);
                expected = encoder.encode(CharBuffer.wrap(ext + lead + trail + ext + norm));
                encoder.reset();
            } catch (CharacterCodingException ex) {
                errln("Unexpected CharacterCodingException: " + ex.getMessage());
                return;
            } catch (RuntimeException ex) {
                if (!currentlybad) {currentlybad = true; badcount++; logln(""); }
View Full Code Here

                    badposindices[i]++;
                    errln("(index=" + i + ") " + converter + " Received: " + source.position() + " Expected: " + positions[i]);
                }
                   
            }
            encoder.reset();
           
            //System.out.println("\n" + hex(target.array()));
            //System.out.println(hex(expected.array()) + "\n" + expected.limit());
            if (!(equals(target, expected, expected.limit()) && target.position() == expected.limit())) {
                if (!currentlybad) {currentlybad = true; badcount++; logln(""); }
View Full Code Here

                (char)0x0001, (char)0x0002
        };
        ByteBuffer bb = ByteBuffer.wrap(byteout);
        CharBuffer cb = CharBuffer.wrap(charin);
        CharBuffer cb2 = CharBuffer.wrap(cb.subSequence(0, 2));
        encoder.reset();
        if (!(encoder.encode(cb2, bb, true)).isOverflow()) {
            errln("Overflow error while encoding ASCII should have occurred.");
        }
    }
    //Test CharsetUTF7
View Full Code Here

       
        ccbs.clear();
        ccus.clear();
       
        //test for overflow buffer error
        encoder.reset();
        ccus.put((char)0x3980); ccus.put((char)0x2715);
        ccbs.put((byte)0x2b); ccbs.put((byte)0x4f); ccbs.put((byte)0x59);
       
        ccbs.limit(ccbs.position());
        ccbs.position(0);
View Full Code Here

        if (!result.isMalformed()) {
            errln("Error while encoding UTF-16LE (2) should have occured.");
        }      
       
        // Test for malform trail surrogate
        encoder.reset();
       
        us.limit(1);
        us.position(0);
        bs.limit(1);
        bs.position(0);
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.