Class CharsetEncoderWithSpecialChar
- java.lang.Object
 - 
- com.microstrategy.web.app.transforms.CharsetEncoderWithSpecialChar
 
 
- 
- All Implemented Interfaces:
 ICharsetTranscoder,IFlushable
public class CharsetEncoderWithSpecialChar extends java.lang.Object implements ICharsetTranscoder, IFlushable
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected ICharsetModifiablemodifier 
- 
Constructor Summary
Constructors Constructor Description CharsetEncoderWithSpecialChar() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidencodeSpecialCharacter(byte b1, byte b2)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.voidflush()This function flush the regular char from byteBuffin to byteBuffOut with correct encoding.
If byteBuffIn is empty, it will do nothing.protected voidpushSpecialChar(byte b1, byte b2)Push the special encoded bytes to the output byte buffer.voidtranscode(MarkupOutput mo, java.lang.String decodeName, java.lang.String encodeName, byte[] data)Called when the charset specified is "SJIS" or "Shift_JIS" (Japanese). 
 - 
 
- 
- 
Field Detail
- 
modifier
protected ICharsetModifiable modifier
 
 - 
 
- 
Method Detail
- 
flush
public void flush() throws java.io.IOException, java.io.UnsupportedEncodingExceptionThis function flush the regular char from byteBuffin to byteBuffOut with correct encoding.
If byteBuffIn is empty, it will do nothing. byteBuffIn will be cleared by this function.
DO NOT OVERRIDE, protected for visibility only.- Specified by:
 flushin interfaceIFlushable- Throws:
 java.io.IOExceptionjava.io.UnsupportedEncodingException
 
- 
pushSpecialChar
protected void pushSpecialChar(byte b1, byte b2) throws java.io.IOException, java.io.UnsupportedEncodingExceptionPush the special encoded bytes to the output byte buffer. If different number of bytes are needed, use flushRegularChar() function follow by byteBuffOut.put(b1).put(b2)...put(bn)- Parameters:
 b1- is the first encoded byteb2- is the second encoded byte- Throws:
 java.io.UnsupportedEncodingExceptionjava.io.IOException
 
- 
encodeSpecialCharacter
protected void encodeSpecialCharacter(byte b1, byte b2) throws java.io.IOException, java.io.UnsupportedEncodingExceptionEncodes 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.IOExceptionjava.io.UnsupportedEncodingException
 
- 
transcode
public void transcode(MarkupOutput mo, java.lang.String decodeName, java.lang.String encodeName, byte[] data) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.io.UnsupportedEncodingException, java.io.IOException
Called when the charset specified is "SJIS" or "Shift_JIS" (Japanese).
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
Calls encodeShiftJISCharacter(byte[], String) for each character (2 bytes)- Specified by:
 transcodein interfaceICharsetTranscoder- Parameters:
 mo- The output objectdecodeName- the charset specified as supported by Java to decode the dataencodeName- the charset to encode the datadata- an array with the bytes as passed by IServer. These bytes are encoded using "UnicodeLittle".- Throws:
 java.lang.IllegalArgumentException- if an error occurs when appending data to the markup outputjava.lang.IllegalStateException- if an error occurs when appending data to the markup outputjava.io.UnsupportedEncodingException- if an error occurs when appending data to the markup outputjava.io.IOException
 
 - 
 
 -