39 |
package gnu.java.io.encode; |
package gnu.java.io.encode; |
40 |
|
|
41 |
import java.io.OutputStream; |
import java.io.OutputStream; |
|
import java.io.CharConversionException; |
|
42 |
import java.io.IOException; |
import java.io.IOException; |
43 |
|
|
44 |
/** |
/** |
55 |
*/ |
*/ |
56 |
public abstract class EncoderEightBitLookup extends Encoder |
public abstract class EncoderEightBitLookup extends Encoder |
57 |
{ |
{ |
|
|
|
58 |
/*************************************************************************/ |
/*************************************************************************/ |
59 |
|
|
60 |
/* |
/* |
61 |
* Class Variables |
* Class Variables |
62 |
*/ |
*/ |
63 |
|
|
64 |
|
private static final byte BAD_CHARACTER = (byte)'?'; |
65 |
|
|
66 |
/** |
/** |
67 |
* This is the second generation lookup table that is loaded when the |
* This is the second generation lookup table that is loaded when the |
141 |
*/ |
*/ |
142 |
public byte[] |
public byte[] |
143 |
convertToBytes(char[] buf, int buf_offset, int len, byte[] bbuf, |
convertToBytes(char[] buf, int buf_offset, int len, byte[] bbuf, |
144 |
int bbuf_offset) throws CharConversionException |
int bbuf_offset) |
145 |
{ |
{ |
146 |
for (int i = 0; i < len; i++) |
for (int i = 0; i < len; i++) |
147 |
{ |
{ |
160 |
} |
} |
161 |
else |
else |
162 |
{ |
{ |
163 |
if (bad_char_set) |
bbuf[bbuf_offset + i] = BAD_CHARACTER; |
|
bbuf[bbuf_offset + i] = encoding_table[bad_char]; |
|
|
else |
|
|
throw new CharConversionException("Encountered unencodable character: " + buf[buf_offset + i]); |
|
164 |
} |
} |
165 |
} |
} |
166 |
else |
else |