Hi Michael,
I used the attached patch so the utf8 hardstatus would display
correctly in my xterm titlebar. Is it ok or how could I improve it?
Thanks in advance.
Roger
On Mon, Apr 23, 2007 at 08:28:17PM +0200, Michael Schroeder wrote:
> On Wed, Mar 28, 2007 at 12:04:09PM +0200, Zvi Har'El wrote:
> > Comparing Unicode, it replaces U+03B1 GREEK SMALL LETTER ALPHA with
> > U+00B1 PLUS-MINUS SIGN and so on, i.e, the Unicode values seem to be
> > taken modulo U+0100.
>
> Yes, it's because StringChar() in ansi.c discards the upper bits.
> To fix this bug we'd have to change the way the string gets stored.
> Note that we can't just simply transcode to the display's encoding,
> as the window may be displayed on multiple displays with different
> encodings...
>
> Cheers,
> Michael.
>
> --
> Michael Schroeder [email protected]
> main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
>
>
diff -uNr screen-4.0.3/ansi.c screen.1/ansi.c
--- screen-4.0.3/ansi.c 2003-12-05 21:57:05.000000000 +0800
+++ screen.1/ansi.c 2009-04-06 13:13:46.000000000 +0800
@@ -1440,6 +1440,19 @@
StringChar(c)
int c;
{
+#ifdef UTF8
+ if (curr->w_encoding == UTF8)
+ {
+ char buf[] = { 0, 0, 0, 0 }; /* last one is the \0 terminator. */
+ int i, len = ToUtf8(buf, c);
+ if (curr->w_stringp >= curr->w_string + MAXSTR - len)
+ curr->w_state = LIT;
+ for (i=0; i<len; i++)
+ *curr->w_stringp++ = buf[i];
+ debug1("StringChar: %s\n", buf);
+ return;
+ }
+#endif
if (curr->w_stringp >= curr->w_string + MAXSTR - 1)
curr->w_state = LIT;
else
diff -uNr screen-4.0.3/display.c screen.1/display.c
--- screen-4.0.3/display.c 2003-12-05 21:45:41.000000000 +0800
+++ screen.1/display.c 2009-04-06 13:25:21.000000000 +0800
@@ -2405,9 +2410,9 @@
AddCStr2(D_TS, 0);
max = D_WS > 0 ? D_WS : (D_width - !D_CLP);
if ((int)strlen(str) > max)
- AddStrn(str, max);
+ AddStrnPlain(str, max);
else
- AddStr(str);
+ AddStrPlain(str);
AddCStr(D_FS);
D_hstatus = 1;
}
@@ -3111,6 +3121,18 @@
}
void
+AddStrPlain(str)
+char *str;
+{
+ register char c;
+
+ ASSERT(display);
+
+ while ((c = *str++))
+ AddChar(c);
+}
+
+void
AddStrn(str, n)
char *str;
int n;
@@ -3133,6 +3155,21 @@
}
void
+AddStrnPlain(str, n)
+char *str;
+int n;
+{
+ register char c;
+
+ ASSERT(display);
+ while ((c = *str++) && n-- > 0)
+ AddChar(c);
+ while (n-- > 0)
+ AddChar(' ');
+}
+
+
+void
Flush()
{
register int l;
diff -uNr screen-4.0.3/extern.h screen.1/extern.h
--- screen-4.0.3/extern.h 2003-08-22 20:27:57.000000000 +0800
+++ screen.1/extern.h 2009-04-06 13:26:18.000000000 +0800
@@ -281,6 +281,8 @@
extern int ResizeDisplay __P((int, int));
extern void AddStr __P((char *));
extern void AddStrn __P((char *, int));
+extern void AddStrPlain __P((char *));
+extern void AddStrnPlain __P((char *, int));
extern void Flush __P((void));
extern void freetty __P((void));
extern void Resize_obuf __P((void));
_______________________________________________
screen-users mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/screen-users