--- slang-1.4.5/src/slang.h.acs	2002-07-09 00:03:57.000000000 -0400
+++ slang-1.4.5/src/slang.h	2002-07-09 00:11:06.000000000 -0400
@@ -1255,6 +1255,8 @@
 
 #ifdef UTF8
 typedef int SLsmg_Char_Type;
+extern SLtt_Char_Type SLcurses_Acs_Map [128];
+#define acs_map SLcurses_Acs_Map
 #define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFFFFFF)
 #define SLSMG_EXTRACT_COLOR(x) (((x)>>24)&0xFF)
 #define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(wchar_t)(ch))|((color)<<24))
@@ -1396,7 +1398,11 @@
 extern void SLsmg_set_screen_start (int *, int *);
 extern void SLsmg_draw_hline (unsigned int);
 extern void SLsmg_draw_vline (int);
+#ifdef UTF8
+extern void SLsmg_draw_object (int, int, SLsmg_Char_Type);
+#else
 extern void SLsmg_draw_object (int, int, unsigned char);
+#endif
 extern void SLsmg_draw_box (int, int, unsigned int, unsigned int);
 extern int SLsmg_get_column(void);
 extern int SLsmg_get_row(void);
@@ -1408,6 +1414,9 @@
 extern int SLsmg_Display_Eight_Bit;
 extern int SLsmg_Tab_Width;
 
+extern int SLsmg_Is_Unicode;
+extern int SLsmg_Setlocale;
+
 #define SLSMG_NEWLINE_IGNORED	0      /* default */
 #define SLSMG_NEWLINE_MOVES	1      /* moves to next line, column 0 */
 #define SLSMG_NEWLINE_SCROLLS	2      /* moves but scrolls at bottom of screen */
@@ -1465,31 +1474,79 @@
 #  define SLSMG_BOARD_CHAR	'#'
 #  define SLSMG_BLOCK_CHAR	'#'
 # else
-#  define SLSMG_HLINE_CHAR	'q'
-#  define SLSMG_VLINE_CHAR	'x'
-#  define SLSMG_ULCORN_CHAR	'l'
-#  define SLSMG_URCORN_CHAR	'k'
-#  define SLSMG_LLCORN_CHAR	'm'
-#  define SLSMG_LRCORN_CHAR	'j'
-#  define SLSMG_CKBRD_CHAR	'a'
-#  define SLSMG_RTEE_CHAR	'u'
-#  define SLSMG_LTEE_CHAR	't'
-#  define SLSMG_UTEE_CHAR	'w'
-#  define SLSMG_DTEE_CHAR	'v'
-#  define SLSMG_PLUS_CHAR	'n'
-#  define SLSMG_DIAMOND_CHAR	'`'
-#  define SLSMG_DEGREE_CHAR	'f'
-#  define SLSMG_PLMINUS_CHAR	'g'
-#  define SLSMG_BULLET_CHAR	'~'
-#  define SLSMG_LARROW_CHAR	','
-#  define SLSMG_RARROW_CHAR	'+'
-#  define SLSMG_DARROW_CHAR	'.'
-#  define SLSMG_UARROW_CHAR	'-'
-#  define SLSMG_BOARD_CHAR	'h'
-#  define SLSMG_BLOCK_CHAR	'0'
+#  define SLSMG_HLINE_CHAR	(acs_map['q'])
+#  define SLSMG_VLINE_CHAR	(acs_map['x'])
+#  define SLSMG_ULCORN_CHAR	(acs_map['l'])
+#  define SLSMG_URCORN_CHAR	(acs_map['k'])
+#  define SLSMG_LLCORN_CHAR	(acs_map['m'])
+#  define SLSMG_LRCORN_CHAR	(acs_map['j'])
+#  define SLSMG_CKBRD_CHAR	(acs_map['a'])
+#  define SLSMG_RTEE_CHAR	(acs_map['u'])
+#  define SLSMG_LTEE_CHAR	(acs_map['t'])
+#  define SLSMG_UTEE_CHAR	(acs_map['v'])
+#  define SLSMG_DTEE_CHAR	(acs_map['w'])
+#  define SLSMG_PLUS_CHAR	(acs_map['n'])
+#  define SLSMG_DIAMOND_CHAR	(acs_map['`'])
+#  define SLSMG_DEGREE_CHAR	(acs_map['f'])
+#  define SLSMG_PLMINUS_CHAR	(acs_map['g'])
+#  define SLSMG_BULLET_CHAR	(acs_map['~'])
+#  define SLSMG_LARROW_CHAR	(acs_map[','])
+#  define SLSMG_RARROW_CHAR	(acs_map['+'])
+#  define SLSMG_DARROW_CHAR	(acs_map['.'])
+#  define SLSMG_UARROW_CHAR	(acs_map['-'])
+#  define SLSMG_BOARD_CHAR	(acs_map['h'])
+#  define SLSMG_BLOCK_CHAR	(acs_map['0'])
+#
+#  define SLSMG_HLINE_CHAR_TERM	'q'
+#  define SLSMG_VLINE_CHAR_TERM	'x'
+#  define SLSMG_ULCORN_CHAR_TERM	'l'
+#  define SLSMG_URCORN_CHAR_TERM	'k'
+#  define SLSMG_LLCORN_CHAR_TERM	'm'
+#  define SLSMG_LRCORN_CHAR_TERM	'j'
+#  define SLSMG_CKBRD_CHAR_TERM	'a'
+#  define SLSMG_RTEE_CHAR_TERM	'u'
+#  define SLSMG_LTEE_CHAR_TERM	't'
+#  define SLSMG_UTEE_CHAR_TERM	'v'
+#  define SLSMG_DTEE_CHAR_TERM	'w'
+#  define SLSMG_PLUS_CHAR_TERM	'n'
+#  define SLSMG_DIAMOND_CHAR_TERM	'`'
+#  define SLSMG_DEGREE_CHAR_TERM	'f'
+#  define SLSMG_PLMINUS_CHAR_TERM	'g'
+#  define SLSMG_BULLET_CHAR_TERM	'~'
+#  define SLSMG_LARROW_CHAR_TERM	','
+#  define SLSMG_RARROW_CHAR_TERM	'+'
+#  define SLSMG_DARROW_CHAR_TERM	'.'
+#  define SLSMG_UARROW_CHAR_TERM	'-'
+#  define SLSMG_BOARD_CHAR_TERM	'h'
+#  define SLSMG_BLOCK_CHAR_TERM	'0'
 # endif				       /* AMIGA */
 #endif				       /* IBMPC_SYSTEM */
 
+#ifdef UTF8
+# define SLSMG_HLINE_CHAR_UNICODE	0x2500
+# define SLSMG_VLINE_CHAR_UNICODE	0x2502
+# define SLSMG_ULCORN_CHAR_UNICODE	0x250c
+# define SLSMG_URCORN_CHAR_UNICODE	0x2510
+# define SLSMG_LLCORN_CHAR_UNICODE	0x2514
+# define SLSMG_LRCORN_CHAR_UNICODE	0x2518
+# define SLSMG_RTEE_CHAR_UNICODE	0x2524
+# define SLSMG_LTEE_CHAR_UNICODE	0x251c
+# define SLSMG_UTEE_CHAR_UNICODE	0x2534
+# define SLSMG_DTEE_CHAR_UNICODE	0x252c
+# define SLSMG_PLUS_CHAR_UNICODE	0x253c
+# define SLSMG_CKBRD_CHAR_UNICODE	0x2592
+# define SLSMG_DIAMOND_CHAR_UNICODE	0x25c6
+# define SLSMG_DEGREE_CHAR_UNICODE	0x00b0
+# define SLSMG_PLMINUS_CHAR_UNICODE	0x00b1
+# define SLSMG_BULLET_CHAR_UNICODE	0x00b7
+# define SLSMG_LARROW_CHAR_UNICODE	0x2190
+# define SLSMG_RARROW_CHAR_UNICODE	0x2192
+# define SLSMG_DARROW_CHAR_UNICODE	0x2193
+# define SLSMG_UARROW_CHAR_UNICODE	0x2191
+# define SLSMG_BOARD_CHAR_UNICODE	0x2592
+# define SLSMG_BLOCK_CHAR_UNICODE	0x25ae
+#endif
+
 #ifndef IBMPC_SYSTEM
 # define SLSMG_COLOR_BLACK		0x000000
 # define SLSMG_COLOR_RED		0x000001
--- slang-1.4.5/src/slcurses.c.acs	2002-07-09 00:03:57.000000000 -0400
+++ slang-1.4.5/src/slcurses.c	2002-07-09 00:09:03.000000000 -0400
@@ -331,40 +331,63 @@
    /* SLtt_set_mono (A_BLINK >> 8, NULL, SLTT_BLINK_MASK); */
    SLtt_set_mono ((A_BOLD|A_UNDERLINE) >> 8, NULL, SLTT_ULINE_MASK|SLTT_BOLD_MASK);
    SLtt_set_mono ((A_REVERSE|A_UNDERLINE) >> 8, NULL, SLTT_ULINE_MASK|SLTT_REV_MASK);
+   
+   SLcurses_init_acs_map();
+
+   return SLcurses_Stdscr;
+}
 
+void SLcurses_init_acs_map()
+{
    if (SLtt_Has_Alt_Charset)
      {
-       SLcurses_Acs_Map[SLSMG_ULCORN_CHAR] = SLSMG_ULCORN_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_URCORN_CHAR] = SLSMG_URCORN_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_LLCORN_CHAR] = SLSMG_LLCORN_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_LRCORN_CHAR] = SLSMG_LRCORN_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_UTEE_CHAR] = SLSMG_UTEE_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_DTEE_CHAR] = SLSMG_DTEE_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_LTEE_CHAR] = SLSMG_LTEE_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_RTEE_CHAR] = SLSMG_RTEE_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_VLINE_CHAR] = SLSMG_VLINE_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_HLINE_CHAR] = SLSMG_HLINE_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_PLUS_CHAR] = SLSMG_PLUS_CHAR | A_ALTCHARSET;
-       SLcurses_Acs_Map[SLSMG_CKBRD_CHAR] = SLSMG_CKBRD_CHAR | A_ALTCHARSET;
+       if (SLsmg_Is_Unicode)
+         {
+           SLcurses_Acs_Map['l'] = SLSMG_ULCORN_CHAR_UNICODE;
+           SLcurses_Acs_Map['k'] = SLSMG_URCORN_CHAR_UNICODE;
+           SLcurses_Acs_Map['m'] = SLSMG_LLCORN_CHAR_UNICODE;
+           SLcurses_Acs_Map['j'] = SLSMG_LRCORN_CHAR_UNICODE;
+           SLcurses_Acs_Map['v'] = SLSMG_UTEE_CHAR_UNICODE;
+           SLcurses_Acs_Map['w'] = SLSMG_DTEE_CHAR_UNICODE;
+           SLcurses_Acs_Map['t'] = SLSMG_LTEE_CHAR_UNICODE;
+           SLcurses_Acs_Map['u'] = SLSMG_RTEE_CHAR_UNICODE;
+           SLcurses_Acs_Map['x'] = SLSMG_VLINE_CHAR_UNICODE;
+           SLcurses_Acs_Map['q'] = SLSMG_HLINE_CHAR_UNICODE;
+           SLcurses_Acs_Map['n'] = SLSMG_PLUS_CHAR_UNICODE;
+           SLcurses_Acs_Map['a'] = SLSMG_CKBRD_CHAR_UNICODE;
+         }
+       else
+	 {
+           SLcurses_Acs_Map['l'] = SLSMG_ULCORN_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['k'] = SLSMG_URCORN_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['m'] = SLSMG_LLCORN_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['j'] = SLSMG_LRCORN_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['v'] = SLSMG_UTEE_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['w'] = SLSMG_DTEE_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['t'] = SLSMG_LTEE_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['u'] = SLSMG_RTEE_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['x'] = SLSMG_VLINE_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['q'] = SLSMG_HLINE_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['n'] = SLSMG_PLUS_CHAR_TERM | A_ALTCHARSET;
+           SLcurses_Acs_Map['a'] = SLSMG_CKBRD_CHAR_TERM | A_ALTCHARSET;
+         }
      }
    else
      {
        /* ugly defaults to use on terminals which don't support graphics */
-       SLcurses_Acs_Map[SLSMG_ULCORN_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_URCORN_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_LLCORN_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_LRCORN_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_UTEE_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_DTEE_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_LTEE_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_RTEE_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_VLINE_CHAR] = '|';
-       SLcurses_Acs_Map[SLSMG_HLINE_CHAR] = '-';
-       SLcurses_Acs_Map[SLSMG_PLUS_CHAR] = '+';
-       SLcurses_Acs_Map[SLSMG_CKBRD_CHAR] = '#';
+       SLcurses_Acs_Map['l'] = '+';
+       SLcurses_Acs_Map['k'] = '+';
+       SLcurses_Acs_Map['m'] = '+';
+       SLcurses_Acs_Map['j'] = '+';
+       SLcurses_Acs_Map['v'] = '+';
+       SLcurses_Acs_Map['w'] = '+';
+       SLcurses_Acs_Map['t'] = '+';
+       SLcurses_Acs_Map['u'] = '+';
+       SLcurses_Acs_Map['x'] = '|';
+       SLcurses_Acs_Map['q'] = '-';
+       SLcurses_Acs_Map['n'] = '+';
+       SLcurses_Acs_Map['a'] = '#';
      }
-
-   return SLcurses_Stdscr;
 }
 
 int SLcurses_wattrset (SLcurses_Window_Type *w, SLtt_Char_Type ch)
--- slang-1.4.5/src/slcurses.h.acs	2002-02-10 02:39:19.000000000 -0500
+++ slang-1.4.5/src/slcurses.h	2002-07-09 00:03:57.000000000 -0400
@@ -141,6 +141,7 @@
 
 extern int SLcurses_nodelay (SLcurses_Window_Type *, int);
 extern SLcurses_Window_Type *SLcurses_initscr (void);
+extern void SLcurses_init_acs_map (void);
 #define initscr SLcurses_initscr
 
 extern int SLcurses_cbreak (void);
--- slang-1.4.5/src/slsmg.c.acs	2002-07-09 00:03:57.000000000 -0400
+++ slang-1.4.5/src/slsmg.c	2002-07-09 00:03:57.000000000 -0400
@@ -10,6 +10,9 @@
 
 #include "slang.h"
 #include "_slang.h"
+#include "slcurses.h"
+
+#include <locale.h>
 
 typedef struct Screen_Type
   {
@@ -44,9 +47,9 @@
 					*/
 
 #ifndef IBMPC_SYSTEM
-#define ALT_CHAR_FLAG 0x80
+static int ALT_CHAR_FLAG=0x80;
 #else
-#define ALT_CHAR_FLAG 0x00
+static int ALT_CHAR_FLAG=0x00;
 #endif
 
 #if SLTT_HAS_NON_BCE_SUPPORT && !defined(IBMPC_SYSTEM)
@@ -54,6 +57,8 @@
 static int Bce_Color_Offset;
 #endif
 
+int SLsmg_Is_Unicode = 0;
+int SLsmg_Setlocale = 1;
 int SLsmg_Newline_Behavior = 0;
 int SLsmg_Backspace_Moves = 0;
 /* Backward compatibility. Not used. */
@@ -184,6 +189,8 @@
      return;/* alt chars not used and the alt bit
 	     * is used to indicate a blink.
 	     */
+   if (SLsmg_Is_Unicode)
+       ALT_CHAR_FLAG=0x00;
 
    if (i) This_Alt_Char = ALT_CHAR_FLAG;
    else This_Alt_Char = 0;
@@ -348,6 +355,8 @@
 #ifndef IBMPC_SYSTEM
    int alt_char_set_flag;
 
+   if (SLsmg_Is_Unicode)
+     ALT_CHAR_FLAG = 0x00;
    alt_char_set_flag = ((This_Color & ALT_CHAR_FLAG)
 			&& ((tt_Use_Blink_For_ACS == NULL)
 			    || (*tt_Use_Blink_For_ACS == 0)));
@@ -1221,6 +1230,20 @@
    Smg_Inited = 0;
 }
 
+static void SLsmg_check_unicode(void)
+{
+    char *s,*t;
+    
+    if (SLsmg_Setlocale)
+		s = setlocale(LC_ALL, "");
+    else
+		s = setlocale(LC_ALL, NULL);
+    if (s && (strstr(s,"UTF-8") || strstr(s,"utf8"))) {
+	    SLsmg_Is_Unicode = 1;
+	    return;
+    }
+    SLsmg_Is_Unicode = 0;
+}
 
 static int init_smg (void)
 {
@@ -1242,6 +1265,8 @@
    This_Col = This_Row = Start_Col = Start_Row = 0;
 
    This_Alt_Char = 0;
+   SLsmg_check_unicode ();
+   SLcurses_init_acs_map ();
    SLsmg_set_color (0);
    Cls_Flag = 1;
 #ifndef IBMPC_SYSTEM
@@ -1386,7 +1411,11 @@
      }
 }
 
+#ifdef UTF8
+void SLsmg_draw_object (int r, int c, SLsmg_Char_Type object)
+#else
 void SLsmg_draw_object (int r, int c, unsigned char object)
+#endif
 {
    This_Row = r;  This_Col = c;
 
@@ -1405,7 +1434,7 @@
 
 void SLsmg_draw_hline (unsigned int n)
 {
-   static unsigned char hbuf[16];
+   SLsmg_Char_Type ch = SLSMG_HLINE_CHAR;
    int count;
    int cmin, cmax;
    int final_col = This_Col + (int) n;
@@ -1421,11 +1450,6 @@
 	return;
      }
 
-   if (hbuf[0] == 0)
-     {
-	SLMEMSET ((char *) hbuf, SLSMG_HLINE_CHAR, 16);
-     }
-
    n = (unsigned int)(cmax - cmin);
    count = n / 16;
 
@@ -1433,10 +1457,10 @@
    This_Color |= ALT_CHAR_FLAG;
    This_Col = cmin;
 
-   SLsmg_write_nchars ((char *) hbuf, n % 16);
-   while (count-- > 0)
+   SLsmg_draw_object(This_Row, This_Col, ch);
+   while (n-- > 0)
      {
-	SLsmg_write_nchars ((char *) hbuf, 16);
+	SLsmg_draw_object(This_Row, This_Col, ch);
      }
 
    This_Color = save_color;
@@ -1445,7 +1469,7 @@
 
 void SLsmg_draw_vline (int n)
 {
-   unsigned char ch = SLSMG_VLINE_CHAR;
+   SLsmg_Char_Type ch = SLSMG_VLINE_CHAR;
    int c = This_Col, rmin, rmax;
    int final_row = This_Row + n;
    int save_color;
@@ -1466,7 +1490,7 @@
    for (This_Row = rmin; This_Row < rmax; This_Row++)
      {
 	This_Col = c;
-	SLsmg_write_nchars ((char *) &ch, 1);
+	SLsmg_draw_object (This_Row, This_Col, ch);
      }
 
    This_Col = c;  This_Row = final_row;
