diff -upr hugs98-Mar2005-patched.orig/libraries/hugsbase/Hugs/Prelude.hs hugs98-Mar2005-patched/libraries/hugsbase/Hugs/Prelude.hs --- hugs98-Mar2005-patched.orig/libraries/hugsbase/Hugs/Prelude.hs 2005-02-17 00:47:33.000000000 +0900 +++ hugs98-Mar2005-patched/libraries/hugsbase/Hugs/Prelude.hs 2005-03-22 19:54:09.000000000 +0900 @@ -1529,11 +1529,15 @@ readLitChar ('\\':s) = readEsc s readEsc _ = [] readLitChar (c:s) = [(c,s)] +primitive isPrint :: Char -> Bool +primitive isRepresentable :: Char -> Bool + showLitChar :: Char -> ShowS -showLitChar c | c > '\DEL' = showChar '\\' . - protectEsc isDigit (shows (fromEnum c)) showLitChar '\DEL' = showString "\\DEL" showLitChar '\\' = showString "\\\\" +showLitChar c | isPrint c && isRepresentable c = showChar c +showLitChar c | c > '\DEL' = showChar '\\' . + protectEsc isDigit (shows (fromEnum c)) showLitChar c | c >= ' ' = showChar c showLitChar '\a' = showString "\\a" showLitChar '\b' = showString "\\b" diff -upr hugs98-Mar2005-patched.orig/src/builtin.c hugs98-Mar2005-patched/src/builtin.c --- hugs98-Mar2005-patched.orig/src/builtin.c 2005-01-14 21:04:59.000000000 +0900 +++ hugs98-Mar2005-patched/src/builtin.c 2005-03-22 19:23:52.000000000 +0900 @@ -325,6 +325,7 @@ PROTO_PRIM(primIsLower); PROTO_PRIM(primIsAlpha); PROTO_PRIM(primIsAlphaNum); PROTO_PRIM(primIsPrint); +PROTO_PRIM(primIsRepresentable); PROTO_PRIM(primToUpper); PROTO_PRIM(primToLower); #if UNICODE_CHARS @@ -544,6 +545,7 @@ static struct primitive builtinPrimTable {"isAlpha", 1, primIsAlpha}, {"isAlphaNum", 1, primIsAlphaNum}, {"isPrint", 1, primIsPrint}, + {"isRepresentable", 1, primIsRepresentable}, {"toUpper", 1, primToUpper}, {"toLower", 1, primToLower}, #if UNICODE_CHARS @@ -1450,6 +1452,7 @@ Char2Bool(primIsLower,isLower(x)) Char2Bool(primIsAlpha,isAlpha(x)) Char2Bool(primIsAlphaNum,isAlphaNum(x)) Char2Bool(primIsPrint,isPrint(x)) +Char2Bool(primIsRepresentable,charIsRepresentable(x)) Char2Char(primToLower,toLower(x)) Char2Char(primToUpper,toUpper(x)) diff -upr hugs98-Mar2005-patched.orig/src/input.c hugs98-Mar2005-patched/src/input.c --- hugs98-Mar2005-patched.orig/src/input.c 2004-10-15 07:08:44.000000000 +0900 +++ hugs98-Mar2005-patched/src/input.c 2005-03-22 19:33:23.000000000 +0900 @@ -1164,7 +1164,11 @@ static Cell local readDecChar() { / String unlexChar(c,quote) /* return string representation of */ Char c; /* character... */ Char quote; { /* protect quote character */ +#if MAX_CHAR_ENCODING + 1 > 12 + static char buffer[MAX_CHAR_ENCODING+1]; +#else static char buffer[12]; +#endif assert(c >= 0); if (isascii(c) && isIn(c,PRINT)) { /* normal printable character */ @@ -1178,6 +1182,11 @@ Char quote; { / buffer[1] = '\0'; } } + else if (!isascii(c) && charIsRepresentable(c) && isPrint(c)) { + String p = buffer; + AddChar(c, p); + *p = '\0'; + } else { /* look for escape code */ Int escs; for (escs=0; escapes[escs].codename; escs++)