----Next_Part(Sat_Dec_13_23_46_57_2003_364)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

さかいです。

From: Nobuo Yamashita <nobsun / sampou.org>
Date: Sat, 13 Dec 2003 00:25:56 +0900 (JST)

> テストバージョンらしいですが、
> http://www.golubovsky.org/software/hugs-patch/hugs_unicode_test.html
> というのがあります。
> 
> $ ./configure --enable-unicode-charscale
> 
> とやってからmakeするとすくなくとも、LANG
_JP.eucJP になっている場合
> EUC-JP で日本語がつかえます。(他はチェックしてませんが)。。。
> 
> Prelude> length "日本語"
> 3
> 
> Char 型がちゃんと1文字をしています。

が、

Prelude> "おはよう"
"\12362\12399\12424\12358"
Prelude> :type "おはよう"
"\12362\12399\12424\12358" :: String

となってしまうのが悲しかったので、
ちゃんとされるようにしてみました。

--
酒井 政裕 / Masahiro Sakai


--
ML: haskell-jp / quickml.com
使い方: http://QuickML.com/
----Next_Part(Sat_Dec_13_23_46_57_2003_364)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="hugs98-Dec2003-unicode-display.diff"

diff -upr hugs98-Dec2003.orig/libraries/Hugs/Prelude.hs hugs98-Dec2003/libraries/Hugs/Prelude.hs
--- hugs98-Dec2003.orig/libraries/Hugs/Prelude.hs	2003-11-19 10:41:34.000000000 +0900
+++ hugs98-Dec2003/libraries/Hugs/Prelude.hs	2003-12-13 23:27:33.000000000 +0900
@@ -1487,12 +1487,13 @@ readLitChar ('\\':s)     eadEsc s
        readEsc _         ]
 readLitChar (c:s)        (c,s)]
 
+primitive isPrint         :: Char -> Bool
+primitive isRepresentable :: Char -> Bool
+
 showLitChar               :: Char -> ShowS
-showLitChar c | c > '\DEL'  howChar '\\' .
-			     protectEsc isDigit (shows (fromEnum c))
 showLitChar '\DEL'          howString "\\DEL"
 showLitChar '\\'            howString "\\\\"
-showLitChar c | c >  '    howChar c
+showLitChar c | isPrint c && isRepresentable c  howChar c
 showLitChar '\a'            howString "\\a"
 showLitChar '\b'            howString "\\b"
 showLitChar '\f'            howString "\\f"
diff -upr hugs98-Dec2003.orig/src/builtin.c hugs98-Dec2003/src/builtin.c
--- hugs98-Dec2003.orig/src/builtin.c	2003-12-02 21:15:49.000000000 +0900
+++ hugs98-Dec2003/src/builtin.c	2003-12-13 23:20:54.000000000 +0900
@@ -329,6 +329,7 @@ PROTO_PRIM(primIsUpper);
 PROTO_PRIM(primIsLower);
 PROTO_PRIM(primIsAlphaNum);
 PROTO_PRIM(primIsPrint);
+PROTO_PRIM(primIsRepresentable);
 PROTO_PRIM(primToUpper);
 PROTO_PRIM(primToLower);
 #if UNICODE_CHARS
@@ -546,6 +547,7 @@ static struct primitive builtinPrimTable
   {"isLower",		1, primIsLower},
   {"isAlphaNum",	1, primIsAlphaNum},
   {"isPrint",		1, primIsPrint},
+  {"isRepresentable",	1, primIsRepresentable},
   {"toUpper",		1, primToUpper},
   {"toLower",		1, primToLower},
 #if UNICODE_CHARS
@@ -1458,6 +1460,7 @@ Char2Bool(primIsUpper,isUpper(x))
 Char2Bool(primIsLower,isLower(x))
 Char2Bool(primIsAlphaNum,isAlphaNum(x))
 Char2Bool(primIsPrint,isPrint(x))
+Char2Bool(primIsRepresentable,charIsRepresentable(x))
 
 Char2Char(primToLower,toLower(x))
 Char2Char(primToUpper,toUpper(x))
diff -upr hugs98-Dec2003.orig/src/input.c hugs98-Dec2003/src/input.c
--- hugs98-Dec2003.orig/src/input.c	2003-12-05 03:14:45.000000000 +0900
+++ hugs98-Dec2003/src/input.c	2003-12-13 23:28:26.000000000 +0900
@@ -1162,18 +1162,20 @@ static Cell local readDecChar() {      /
 String unlexChar(c,quote)              /* return string representation of  */
 Char c;                                /* character...                     */
 Char quote; {                          /* protect quote character          */
-    static char buffer[12];	       					   
+    static char buffer[MAX_CHAR_ENCODING+1];
 
     assert(c > );
-    if (isLatin1(c) && isIn(c,PRINT)) {/* normal printable character       */
+    if (isPrint(c) && charIsRepresentable(c)) {/* normal printable character       */
 	if (cuote || c\\') {     /* look for quote of approp. kind   */
 	    buffer[0]  \\';           
 	    buffer[1]  char)c;
 	    buffer[2]  \0';
 	}
 	else {
-	    buffer[0]  char)c;
-	    buffer[1]  \0';
+	    String p  uffer;
+	    buffer[0]  \0';
+	    AddChar(c, p);
+	    p[0]  \0';
 	}
     }
     else {                             /* look for escape code             */
diff -upr hugs98-Dec2003.orig/src/output.c hugs98-Dec2003/src/output.c
--- hugs98-Dec2003.orig/src/output.c	2003-12-04 22:53:51.000000000 +0900
+++ hugs98-Dec2003/src/output.c	2003-12-13 23:29:37.000000000 +0900
@@ -96,8 +96,9 @@ Int c; {			       				       
 								       
 static Void local putStr(s)            /* print string                 	   */
 String s; {			       				       
-    for (; *s; s++) {		       				       
-	Putc(*s,outputStream);	       				       
+    Char c;
+    while (c  xtractChar(s)) {
+	Putc(c,outputStream);        
 #if DEBUG_SHOWSC || OBSERVATIONS
 	outColumn++;		       				       
 #endif				       				       
@@ -767,8 +768,15 @@ Text t; {
 
 	lastWasEsc    *ch\\');
 	lastWasSO     scO);
-	for (; *ch; c  ch++)
-	    putChr(*ch);
+
+	{
+	    Char tmp;
+	    while (tmp  xtractChar(ch)) {
+		putChr(tmp);
+		c  mp;
+	    }
+	}
+            
 	lastWasDigit  isascii(c) && isdigit(c));
     }
     putChr('\"');

----Next_Part(Sat_Dec_13_23_46_57_2003_364)----