[kaffe] CVS kaffe (kaz): libraries/javalib/kaffe/io/ByteToCharConverter.java,
Kaffe CVS
cvs-commits at kaffe.org
Wed Oct 6 15:35:45 PDT 2004
PatchSet 5253
Date: 2004/10/06 22:31:20
Author: kaz
Branch: HEAD
Tag: (none)
Log:
2004-10-07 Ito Kazumitsu <kaz at maczuka.gcd.org>
* libraries/javalib/kaffe/io/ByteToCharConverter.java,
libraries/javalib/kaffe/io/CharToByteConverter.java,
libraries/javalib/kaffe/io/ConverterAlias.java:
When to use iconv, use encoding names defined in iconv.
New method iconvAlias in ConverterAlias.java returns such
names.
Members:
ChangeLog:1.2807->1.2808
libraries/javalib/kaffe/io/ByteToCharConverter.java:1.24->1.25
libraries/javalib/kaffe/io/CharToByteConverter.java:1.17->1.18
libraries/javalib/kaffe/io/ConverterAlias.java:1.19->1.20
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2807 kaffe/ChangeLog:1.2808
--- kaffe/ChangeLog:1.2807 Tue Oct 5 22:11:16 2004
+++ kaffe/ChangeLog Wed Oct 6 22:31:20 2004
@@ -1,3 +1,12 @@
+2004-10-07 Ito Kazumitsu <kaz at maczuka.gcd.org>
+
+ * libraries/javalib/kaffe/io/ByteToCharConverter.java,
+ libraries/javalib/kaffe/io/CharToByteConverter.java,
+ libraries/javalib/kaffe/io/ConverterAlias.java:
+ When to use iconv, use encoding names defined in iconv.
+ New method iconvAlias in ConverterAlias.java returns such
+ names.
+
2004-10-05 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/javax/imageio/spi/ImageReaderSpi.java,
Index: kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java
diff -u kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java:1.24 kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java:1.25
--- kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java:1.24 Mon Mar 22 11:25:30 2004
+++ kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java Wed Oct 6 22:31:23 2004
@@ -109,27 +109,27 @@
if (cls == noConverter) {
return (null);
}
+ String realenc = ConverterAlias.alias(enc);
if (cls == useIconv) {
- return (getByteToCharIconv(ConverterAlias.alias(enc)));
+ return (getByteToCharIconv(ConverterAlias.iconvAlias(realenc)));
}
try {
if (cls == null) {
- String realenc = ConverterAlias.alias(enc);
if (ConverterAlias.shouldUseIconv(realenc)) {
- ByteToCharConverter conv = getByteToCharIconv(realenc);
+ ByteToCharConverter conv = getByteToCharIconv(ConverterAlias.iconvAlias(realenc));
cache.put(enc, (conv != null ? useIconv : noConverter));
return (conv);
}
- realenc = encodingRoot + ".ByteToChar" + realenc;
- cls = Class.forName(realenc);
+ String enccls = encodingRoot + ".ByteToChar" + realenc;
+ cls = Class.forName(enccls);
cache.put(enc, cls);
}
return ((ByteToCharConverter)cls.newInstance());
}
catch (ClassNotFoundException _) {
try {
- String realenc = encodingRoot + ".ByteToChar" + ConverterAlias.alias(enc);
- InputStream in = ClassLoader.getSystemResourceAsStream(realenc.replace('.', '/') + ".ser");
+ String enccls = encodingRoot + ".ByteToChar" + realenc;
+ InputStream in = ClassLoader.getSystemResourceAsStream(enccls.replace('.', '/') + ".ser");
if (in != null) {
ObjectInputStream oin = new ObjectInputStream(in);
Object obj = oin.readObject();
@@ -149,7 +149,7 @@
catch (InstantiationException _) {
}
// Finally, try iconv.
- ByteToCharConverter conv = getByteToCharIconv(ConverterAlias.alias(enc));
+ ByteToCharConverter conv = getByteToCharIconv(realenc);
cache.put(enc, (conv != null ? useIconv : noConverter));
return (conv);
}
Index: kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java
diff -u kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java:1.17 kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java:1.18
--- kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java:1.17 Mon Mar 22 11:25:30 2004
+++ kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java Wed Oct 6 22:31:23 2004
@@ -86,27 +86,27 @@
if (cls == noConverter) {
return (null);
}
+ String realenc = ConverterAlias.alias(enc);
if (cls == useIconv) {
- return (getCharToByteIconv(ConverterAlias.alias(enc)));
+ return (getCharToByteIconv(ConverterAlias.iconvAlias(realenc)));
}
try {
if (cls == null) {
- String realenc = ConverterAlias.alias(enc);
if (ConverterAlias.shouldUseIconv(realenc)) {
- CharToByteConverter conv = getCharToByteIconv(realenc);
+ CharToByteConverter conv = getCharToByteIconv(ConverterAlias.iconvAlias(realenc));
cache.put(enc, (conv != null ? useIconv : noConverter));
return (conv);
}
- realenc = encodingRoot + ".CharToByte" + realenc;
- cls = Class.forName(realenc);
+ String enccls = encodingRoot + ".CharToByte" + realenc;
+ cls = Class.forName(enccls);
cache.put(enc, cls);
}
return (CharToByteConverter)cls.newInstance();
}
catch (ClassNotFoundException _) {
try {
- String realenc = encodingRoot + ".CharToByte" + ConverterAlias.alias(enc);
- InputStream in = ClassLoader.getSystemResourceAsStream(realenc.replace('.', '/') + ".ser");
+ String enccls = encodingRoot + ".CharToByte" + realenc;
+ InputStream in = ClassLoader.getSystemResourceAsStream(enccls.replace('.', '/') + ".ser");
if (in != null) {
ObjectInputStream oin = new ObjectInputStream(in);
Object obj = oin.readObject();
@@ -126,7 +126,7 @@
catch (IllegalAccessException _) {
}
// Finally, try iconv.
- CharToByteConverter conv = getCharToByteIconv(ConverterAlias.alias(enc));
+ CharToByteConverter conv = getCharToByteIconv(realenc);
cache.put(enc, (conv != null ? useIconv : noConverter));
return (conv);
}
Index: kaffe/libraries/javalib/kaffe/io/ConverterAlias.java
diff -u kaffe/libraries/javalib/kaffe/io/ConverterAlias.java:1.19 kaffe/libraries/javalib/kaffe/io/ConverterAlias.java:1.20
--- kaffe/libraries/javalib/kaffe/io/ConverterAlias.java:1.19 Wed Sep 29 16:44:10 2004
+++ kaffe/libraries/javalib/kaffe/io/ConverterAlias.java Wed Oct 6 22:31:24 2004
@@ -38,7 +38,7 @@
alias.put("IBM819", "8859_1");
alias.put("CP819", "8859_1");
alias.put("CSISOLATIN1", "8859_1");
- useIconv.put("8859_1", "Y");
+ useIconv.put("8859_1", "ISO-8859-1");
alias.put("ISO_8859-2:1987", "8859_2");
alias.put("ISO-IR-101", "8859_2");
@@ -47,7 +47,7 @@
alias.put("LATIN2", "8859_2");
alias.put("L2", "8859_2");
alias.put("CSISOLATIN2", "8859_2");
- useIconv.put("8859_2", "Y");
+ useIconv.put("8859_2", "ISO-8859-2");
alias.put("ISO_8859-3:1988", "8859_3");
alias.put("ISO-IR-109", "8859_3");
@@ -56,7 +56,7 @@
alias.put("LATIN3", "8859_3");
alias.put("L3", "8859_3");
alias.put("CSISOLATIN3", "8859_3");
- useIconv.put("8859_3", "Y");
+ useIconv.put("8859_3", "ISO-8859-3");
alias.put("ISO_8859-4:1988", "8859_4");
alias.put("ISO-IR-110", "8859_4");
@@ -65,7 +65,7 @@
alias.put("LATIN4", "8859_4");
alias.put("L4", "8859_4");
alias.put("CSISOLATIN4", "8859_4");
- useIconv.put("8859_4", "Y");
+ useIconv.put("8859_4", "ISO-8859-4");
alias.put("ISO_8859-5:1988", "8859_5");
alias.put("ISO-IR-144", "8859_5");
@@ -73,7 +73,7 @@
alias.put("ISO-8859-5", "8859_5");
alias.put("CYRILLIC", "8859_5");
alias.put("CSISOLATINCYRILLIC", "8859_5");
- useIconv.put("8859_5", "Y");
+ useIconv.put("8859_5", "ISO-8859-5");
alias.put("ISO_8859-6:1987", "8859_6");
alias.put("ISO-IR-127", "8859_6");
@@ -83,7 +83,7 @@
alias.put("ASMO-708", "8859_6");
alias.put("ARABIC", "8859_6");
alias.put("CSISOLATINARABIC", "8859_6");
- useIconv.put("8859_6", "Y");
+ useIconv.put("8859_6", "ISO-8859-6");
alias.put("ISO_8859-7:1987", "8859_7");
alias.put("ISO-IR-126", "8859_7");
@@ -94,7 +94,7 @@
alias.put("GREEK", "8859_7");
alias.put("GREEK8", "8859_7");
alias.put("CSISOLATINGREEK", "8859_7");
- useIconv.put("8859_7", "Y");
+ useIconv.put("8859_7", "ISO-8859-7");
alias.put("ISO_8859-8:1988", "8859_8");
alias.put("ISO-IR-138", "8859_8");
@@ -102,7 +102,7 @@
alias.put("ISO-8859-8", "8859_8");
alias.put("HEBREW", "8859_8");
alias.put("CSISOLATINHEBREW", "8859_8");
- useIconv.put("8859_8", "Y");
+ useIconv.put("8859_8", "ISO-8859-8");
alias.put("ISO_8859-9:1989", "8859_9");
alias.put("ISO-IR-148", "8859_9");
@@ -111,23 +111,23 @@
alias.put("LATIN5", "8859_9");
alias.put("L5", "8859_9");
alias.put("CSISOLATIN5", "8859_9");
- useIconv.put("8859_9", "Y");
+ useIconv.put("8859_9", "ISO-8859-9");
alias.put("EBCDIC", "CP1046");
useIconv.put("CP1046", "Y");
alias.put("UTF-8", "UTF8");
- useIconv.put("UTF8", "Y");
+ useIconv.put("UTF8", "UTF-8");
alias.put("KOI8-R", "KOI8_R");
alias.put("CSKOI8R", "KOI8_R");
- useIconv.put("KOI8_R", "Y");
+ useIconv.put("KOI8_R", "KOI8-R");
alias.put("EUCJP", "EUC-JP");
alias.put("EUC_JP", "EUC-JP");
alias.put("EUCJIS", "EUC-JP");
alias.put("CSEUCPKDFMTJAPANESE","EUC-JP");
- useIconv.put("EUC-JP", "Y");
+ useIconv.put("EUC-JP", "EUC-JP");
alias.put("US-ASCII", "ASCII");
alias.put("ANSI_X3.4-1968", "ASCII");
@@ -139,12 +139,12 @@
alias.put("IBM367", "ASCII");
alias.put("CP367", "ASCII");
alias.put("CPASCII", "ASCII");
- useIconv.put("ASCII", "Y");
+ useIconv.put("ASCII", "ASCII");
alias.put("UNICODEBIGUNMARKED", "UTF-16BE");
- useIconv.put("UTF-16BE", "Y");
+ useIconv.put("UTF-16BE", "UTF-16BE");
alias.put("UNICODELITTLEUNMARKED", "UTF-16LE");
- useIconv.put("UTF-16LE", "Y");
+ useIconv.put("UTF-16LE", "UTF-16LE");
/* add more here */
}
@@ -172,5 +172,16 @@
name = name.toUpperCase();
Object obj = useIconv.get(name);
return obj != null ? true : false;
+ }
+
+ /**
+ * Returns encoding name to be used for calling iconv.
+ *
+ * @param name of the encoding.
+ * @return Encoding name to be used for calling iconv.
+ */
+ static String iconvAlias(String name) {
+ String iconvEnc = (String)(useIconv.get(name.toUpperCase()));
+ return iconvEnc == null ? name : iconvEnc;
}
}
More information about the kaffe
mailing list