classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Patch: character encoder/decoder cleanup/fixes


From: Jeroen Frijters
Subject: [cp-patches] FYI: Patch: character encoder/decoder cleanup/fixes
Date: Wed, 17 Nov 2004 15:43:56 +0100

Hi,

I committed the attached patch to remove the throwing of
CharConversionException from the character encoders/decoders.

For encoders, unsupported characters are now always replaced with a '?'
byte and for the UTF8 decoder, invalid UTF-8 bytes are replaced by a
Unicode REPLACEMENT CHARACTER (\uFFFD) in the output stream.

This is more consistent with the JDK and removes several bogus exception
handlers.

Regards,
Jeroen

2004-11-17  Jeroen Frijters  <address@hidden>

        * gnu/java/io/decode/Decoder.java: Removed throws
        CharConversionException from the various methods.
        * gnu/java/io/decode/DecoderUTF8.java
        (REPLACEMENT_CHARACTER): New field.
        (charsInByteArray, convertToChars, read): Removed throws
        CharConversionException and reimplemented algorithm to replace
        illegal UTF-8 sequences with REPLACEMENT_CHARACTER instead of
        throwing an exception.
        * gnu/java/io/encode/Encoder.java
        (bad_char, bad_char_set, setBadCharValue): Removed.
        (bytesInCharArray, convertToBytes): Removed throws
        CharConversionException.
        * gnu/java/io/encode/EncoderEightBitLookup.java
        (BAD_CHARACTER): New field.
        (convertToBytes): Changed to always replace invalid characters
with
        BAD_CHARACTER instead of throwing an exception if bad_char
hadn't
        been set.
        * java/io/OutputStreamWriter.java
        (OutputStreamWriter): Removed call to Encoder.setBadCharValue().
        * java/lang/String.java: Removed try/catch block around
        Encoder/Decoder calls that no longer throw
CharConversionException.

Attachment: decoder.patch
Description: decoder.patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]