diff options
author | Sven de Marothy <sven@physto.se> | 2005-04-12 00:48:47 +0000 |
---|---|---|
committer | Sven de Marothy <sven@physto.se> | 2005-04-12 00:48:47 +0000 |
commit | 1e1af34c7d8a7e2f9fe6f213a5803f6e36950426 (patch) | |
tree | 23a7466a87f210ecb5d855bc47f62744454e8a65 | |
parent | 6a61c24a68a7bd62243748a0c44f3884548e70ab (diff) | |
download | classpath-1e1af34c7d8a7e2f9fe6f213a5803f6e36950426.tar.gz |
2005-04-12 Sven de Marothy <sven@physto.se>
* gnu/java/nio/charset/Provider.java: Add UnicodeLittle.
* gnu/java/nio/charset/UnicodeLittle.java: New file.
* gnu/java/nio/charset/UTF_16.java: UnicodeBig is an alias.
* gnu/java/nio/charset/UTF_16BE.java,
* gnu/java/nio/charset/UTF_16LE.java: No byte-order mark.
* gnu/java/nio/charset/UTF_16Encoder.java (encodeLoop): Fixed bug.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | gnu/java/nio/charset/Provider.java | 3 | ||||
-rw-r--r-- | gnu/java/nio/charset/UTF_16.java | 2 | ||||
-rw-r--r-- | gnu/java/nio/charset/UTF_16BE.java | 2 | ||||
-rw-r--r-- | gnu/java/nio/charset/UTF_16Encoder.java | 6 | ||||
-rw-r--r-- | gnu/java/nio/charset/UTF_16LE.java | 2 | ||||
-rw-r--r-- | gnu/java/nio/charset/UnicodeLittle.java | 74 |
7 files changed, 93 insertions, 5 deletions
@@ -1,3 +1,12 @@ +2005-04-12 Sven de Marothy <sven@physto.se> + + * gnu/java/nio/charset/Provider.java: Add UnicodeLittle. + * gnu/java/nio/charset/UnicodeLittle.java: New file. + * gnu/java/nio/charset/UTF_16.java: UnicodeBig is an alias. + * gnu/java/nio/charset/UTF_16BE.java, + * gnu/java/nio/charset/UTF_16LE.java: No byte-order mark. + * gnu/java/nio/charset/UTF_16Encoder.java (encodeLoop): Fixed bug. + 2005-04-11 Michael Koch <konqueror@gmx.de> * java/net/InetAddress.java diff --git a/gnu/java/nio/charset/Provider.java b/gnu/java/nio/charset/Provider.java index 781c10ec9..91d1335ed 100644 --- a/gnu/java/nio/charset/Provider.java +++ b/gnu/java/nio/charset/Provider.java @@ -106,6 +106,9 @@ public final class Provider extends CharsetProvider // UTF-16 addCharset (new UTF_16 ()); + // UTF-16LE (marked) + addCharset (new UnicodeLittle ()); + // Windows-1250 aka cp-1250 (East European) addCharset (new Windows1250 ()); diff --git a/gnu/java/nio/charset/UTF_16.java b/gnu/java/nio/charset/UTF_16.java index 28c9445e3..2ba226d80 100644 --- a/gnu/java/nio/charset/UTF_16.java +++ b/gnu/java/nio/charset/UTF_16.java @@ -57,7 +57,7 @@ final class UTF_16 extends Charset /* These names are provided by * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL */ - "ISO-10646-UCS-2", "unicode", "csUnicode", "ucs-2" + "ISO-10646-UCS-2", "unicode", "csUnicode", "ucs-2", "UnicodeBig" }); } diff --git a/gnu/java/nio/charset/UTF_16BE.java b/gnu/java/nio/charset/UTF_16BE.java index dc0d13698..0f38e4346 100644 --- a/gnu/java/nio/charset/UTF_16BE.java +++ b/gnu/java/nio/charset/UTF_16BE.java @@ -79,6 +79,6 @@ final class UTF_16BE extends Charset public CharsetEncoder newEncoder () { - return new UTF_16Encoder (this, UTF_16Encoder.BIG_ENDIAN, true); + return new UTF_16Encoder (this, UTF_16Encoder.BIG_ENDIAN, false); } } diff --git a/gnu/java/nio/charset/UTF_16Encoder.java b/gnu/java/nio/charset/UTF_16Encoder.java index b396c7304..a71673037 100644 --- a/gnu/java/nio/charset/UTF_16Encoder.java +++ b/gnu/java/nio/charset/UTF_16Encoder.java @@ -117,9 +117,11 @@ final class UTF_16Encoder extends CharsetEncoder } else { - out.order(originalBO); if (out.remaining () < 2) - return CoderResult.OVERFLOW; + { + out.order(originalBO); + return CoderResult.OVERFLOW; + } out.putChar (c); inPos++; } diff --git a/gnu/java/nio/charset/UTF_16LE.java b/gnu/java/nio/charset/UTF_16LE.java index 87ceab303..0a042ed29 100644 --- a/gnu/java/nio/charset/UTF_16LE.java +++ b/gnu/java/nio/charset/UTF_16LE.java @@ -78,6 +78,6 @@ final class UTF_16LE extends Charset public CharsetEncoder newEncoder () { - return new UTF_16Encoder (this, UTF_16Encoder.LITTLE_ENDIAN, true); + return new UTF_16Encoder (this, UTF_16Encoder.LITTLE_ENDIAN, false); } } diff --git a/gnu/java/nio/charset/UnicodeLittle.java b/gnu/java/nio/charset/UnicodeLittle.java new file mode 100644 index 000000000..e82e9c5c8 --- /dev/null +++ b/gnu/java/nio/charset/UnicodeLittle.java @@ -0,0 +1,74 @@ +/* UnicodeLittle.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.nio.charset; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; + +/** + * UTF-16 little endian with a byte-order mark + * Included for java.io completeness. + * ("UTF-16" is equal to UnicodeBig, and + * UTF-16BE/LE do not have a BOM + */ +final class UnicodeLittle extends Charset +{ + UnicodeLittle () + { + super ("UnicodeLittle", new String[] {}); + } + + public boolean contains (Charset cs) + { + return cs instanceof US_ASCII || cs instanceof ISO_8859_1 + || cs instanceof UTF_8 || cs instanceof UTF_16BE + || cs instanceof UTF_16LE || cs instanceof UTF_16; + } + + public CharsetDecoder newDecoder () + { + return new UTF_16Decoder (this, UTF_16Decoder.UNKNOWN_ENDIAN); + } + + public CharsetEncoder newEncoder () + { + return new UTF_16Encoder (this, UTF_16Encoder.LITTLE_ENDIAN, true); + } +} |