aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
Diffstat (limited to 'libjava')
-rw-r--r--libjava/classpath/ChangeLog.gcj13
-rw-r--r--libjava/classpath/gnu/java/nio/charset/ByteCharset.java16
-rw-r--r--libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java13
-rw-r--r--libjava/classpath/gnu/java/nio/charset/US_ASCII.java15
4 files changed, 56 insertions, 1 deletions
diff --git a/libjava/classpath/ChangeLog.gcj b/libjava/classpath/ChangeLog.gcj
index 3503a07..81112e5 100644
--- a/libjava/classpath/ChangeLog.gcj
+++ b/libjava/classpath/ChangeLog.gcj
@@ -1,5 +1,18 @@
2006-09-25 Tom Tromey <tromey@redhat.com>
+ PR libgcj/29178:
+ * gnu/java/nio/charset/US_ASCII.java (Encoder.canEncode): New method.
+ (Encoder.canEncode): Likewise.
+ (Encoder.encodeLoop): Return unmappable for all non-ASCII characters.
+ * gnu/java/nio/charset/ByteCharset.java (Encoder.canEncode): New
+ method.
+ (Encoder.canEncode): Likewise.
+ * gnu/java/nio/charset/ISO_8859_1.java (Encoder.canEncode): New
+ method.
+ (Encoder.canEncode): Likewise.
+
+2006-09-25 Tom Tromey <tromey@redhat.com>
+
* native/fdlibm/mprec.c (mprec_calloc): Renamed.
(Balloc): Updated.
diff --git a/libjava/classpath/gnu/java/nio/charset/ByteCharset.java b/libjava/classpath/gnu/java/nio/charset/ByteCharset.java
index 2cc91b8..da0fdcb 100644
--- a/libjava/classpath/gnu/java/nio/charset/ByteCharset.java
+++ b/libjava/classpath/gnu/java/nio/charset/ByteCharset.java
@@ -156,6 +156,22 @@ abstract class ByteCharset extends Charset
}
}
+ public boolean canEncode(char c)
+ {
+ byte b = (c < lookup.length) ? lookup[c] : 0;
+ return b != 0 || c == 0;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ {
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
diff --git a/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java b/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java
index cc06ecd..2a3073a 100644
--- a/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java
+++ b/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java
@@ -128,6 +128,19 @@ final class ISO_8859_1 extends Charset
super (cs, 1.0f, 1.0f);
}
+ public boolean canEncode(char c)
+ {
+ return c <= 0xff;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
diff --git a/libjava/classpath/gnu/java/nio/charset/US_ASCII.java b/libjava/classpath/gnu/java/nio/charset/US_ASCII.java
index d26f7ff..8888416 100644
--- a/libjava/classpath/gnu/java/nio/charset/US_ASCII.java
+++ b/libjava/classpath/gnu/java/nio/charset/US_ASCII.java
@@ -134,6 +134,19 @@ final class US_ASCII extends Charset
super (cs, 1.0f, 1.0f);
}
+ public boolean canEncode(char c)
+ {
+ return c <= 0x7f;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
@@ -141,7 +154,7 @@ final class US_ASCII extends Charset
{
char c = in.get ();
- if (c > Byte.MAX_VALUE)
+ if (c > 0x7f)
{
in.position (in.position () - 1);
return CoderResult.unmappableForLength (1);