Class EncodeSpecialStreamingContext

    • Field Detail

      • encoder

        protected java.nio.charset.CharsetEncoder encoder
      • decoder

        protected java.nio.charset.CharsetDecoder decoder
      • charBuff

        protected java.nio.CharBuffer charBuff
      • byteBuffIn

        protected java.nio.ByteBuffer byteBuffIn
      • byteBuffOut

        protected java.nio.ByteBuffer byteBuffOut
      • encodeCharsetName

        protected java.lang.String encodeCharsetName
      • out

        protected java.io.OutputStream out
    • Constructor Detail

      • EncodeSpecialStreamingContext

        public EncodeSpecialStreamingContext​(ContainerServices cs,
                                             java.lang.String encodeName)
    • Method Detail

      • consume

        public void consume​(int contentLength,
                            java.io.InputStream src)
                     throws java.lang.Exception
        Description copied from interface: IContentConsumer
        Request to a consumer to consume specified number of bytes from the input stream
        Specified by:
        consume in interface IContentConsumer
        Overrides:
        consume in class StreamingContext
        Parameters:
        contentLength - number of bytes to consume.
        src - source input stream
        Throws:
        java.lang.Exception
      • consume

        public void consume​(java.lang.String decodeCharsetName,
                            int contentLength,
                            java.io.InputStream src)
                     throws java.lang.Exception
        Description copied from interface: IContentConsumer
        Request to a consumer to consume specified number of bytes from the input stream
        Specified by:
        consume in interface IContentConsumer
        Overrides:
        consume in class StreamingContext
        Parameters:
        decodeCharsetName - decoder charset name
        contentLength - number of bytes to consume.
        src - source input stream
        Throws:
        java.lang.Exception
      • encodeSpecialCharacter

        protected void encodeSpecialCharacter​(byte b1,
                                              byte b2)
                                       throws java.io.IOException,
                                              java.io.UnsupportedEncodingException
        Encodes one character as Shift JIS
        This is done to special-encode some problematic characters into SJIS because they are not properly encoded by Java.
        For more information see: http://www-01.ibm.com/support/docview.wss?rs=133&context=SS5RG2&dc=DB560&dc=DB520&uid=swg21064197&loc=en_US&cs=UTF-8&lang=en&rss=ct133rational In addition to the characters mentioned on this link we also special encode circled numbers from 1 to 20 which also break in Japanese
        This can be overwritten to encode extra characters
        The recommended overwritten code snippet:
        protected void encodeShiftJISCharacter(byte b1, byte b2) throws UnsupportedEncodingException {
            if (b1 == 0x15 && b2 == 0x20) {//double dash
                pushSpecialChar((byte) 0x81, (byte) 0x5c)
            } else {
                super.encodeShiftJISCharactor(b1,b2);
            }
        }
        Throws:
        java.io.IOException
        java.io.UnsupportedEncodingException
      • transcode

        protected void transcode​(byte[] data,
                                 int range)
                          throws java.io.IOException,
                                 java.nio.charset.CharacterCodingException
        Throws:
        java.io.IOException
        java.nio.charset.CharacterCodingException
      • flush

        public void flush()
                   throws java.nio.charset.CharacterCodingException,
                          java.io.IOException
        Specified by:
        flush in interface IFlushable
        Throws:
        java.nio.charset.CharacterCodingException
        java.io.IOException