The encoding 646 once again

Martin Kahlert martin.kahlert@infineon.com
Wed Mar 27 08:48:00 GMT 2002


A long time ago Tom wrote:
> Martin> Why can't we alias 646 simply to UTF-8?
>  
> It isn't really correct.  I'm not overly concerned about the corner
> cases though (the difference is that in theory with ASCII you should
> get an error if you see a byte >0x7f, but with UTF-8 we'll try to
> interpret it).
> 
> I think something like this would be fine, especially if it comes with
> a big comment explaining why it is required (like the one in libgcj).
> Do you want to try it?  I think it might suffice to fix
> gcc/java/lex.c.


Hi!
This patch will free us from the obligatory --encoding=UTF-8 on 
Solaris 2.7 (and perhaps other versions).

Bye,
Martin.


2002-03-27  Martin Kahlert  <martin.kahlert@infineon.com>

	* lex.c (java_new_lexer): Alias "646" to DEFAULT_ENCODING

diff -ru gcc-20020325.old/gcc/java/lex.c gcc-20020325/gcc/java/lex.c
--- gcc-20020325.old/gcc/java/lex.c	Sat Mar 23 00:59:20 2002
+++ gcc-20020325/gcc/java/lex.c	Wed Mar 27 09:38:10 2002
@@ -290,8 +290,13 @@
       /* If iconv failed, use the internal decoder if the default
 	 encoding was requested.  This code is used on platforms where
 	 iconv exists but is insufficient for our needs.  For
-	 instance, on Solaris 2.5 iconv cannot handle UTF-8 or UCS-2.  */
-      if (strcmp (encoding, DEFAULT_ENCODING))
+	 instance, on Solaris 2.5 iconv cannot handle UTF-8 or UCS-2.
+
+        On Solaris the default encoding, as returned by nl_langinfo(),
+        is `646' (aka ASCII), but the Solaris iconv_open() doesn't
+        understand that.  We work around that by pretending
+        `646' to be the same as UTF-8   */
+      if (strcmp (encoding, DEFAULT_ENCODING) && strcmp (encoding, "646"))
 	enc_error = 1;
 #ifdef HAVE_ICONV
       else


-- 
The early bird catches the worm. If you want something else for       
breakfast, get up later.



More information about the Java-patches mailing list