aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/gcj/convert/BytesToUnicode.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/gcj/convert/BytesToUnicode.java')
-rw-r--r--libjava/gnu/gcj/convert/BytesToUnicode.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/libjava/gnu/gcj/convert/BytesToUnicode.java b/libjava/gnu/gcj/convert/BytesToUnicode.java
index f33720aa227..e3afe3ee97b 100644
--- a/libjava/gnu/gcj/convert/BytesToUnicode.java
+++ b/libjava/gnu/gcj/convert/BytesToUnicode.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation
This file is part of libgcj.
@@ -8,6 +8,8 @@ details. */
package gnu.gcj.convert;
+import java.nio.charset.Charset;
+
public abstract class BytesToUnicode extends IOConverter
{
/** Buffer to read bytes from.
@@ -104,11 +106,20 @@ public abstract class BytesToUnicode extends IOConverter
try
{
// We pass the original name to iconv and let it handle
- // its own aliasing.
+ // its own aliasing. Note that we intentionally prefer
+ // iconv over nio.
return new Input_iconv (encoding);
}
catch (Throwable _)
{
+ // Ignore, and try the next method.
+ }
+ try
+ {
+ return new BytesToCharsetAdaptor(Charset.forName(encoding));
+ }
+ catch (Throwable _)
+ {
throw new java.io.UnsupportedEncodingException(encoding
+ " (" + ex + ')');
}