[801] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r802 - branches/barnowl_unicode/owl

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:09:52 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Tue,  8 Jan 2008 00:11:55 -0500 (EST)

Author: asedeno
Date: 2008-01-08 00:11:55 -0500 (Tue, 08 Jan 2008)
New Revision: 802

Modified:
   branches/barnowl_unicode/owl/owl.c
Log:
unicode/glib branch
* more strict utf-8 byte fetching.
This probably still needs more work.


Modified: branches/barnowl_unicode/owl/owl.c
===================================================================
--- branches/barnowl_unicode/owl/owl.c	2008-01-08 05:10:30 UTC (rev 801)
+++ branches/barnowl_unicode/owl/owl.c	2008-01-08 05:11:55 UTC (rev 802)
@@ -556,13 +556,13 @@
 	memset(utf8buf,'\0',7);
 	utf8buf[0] = j;
 
-	if (~j & 0x20) bytes = 2;
-	else if (~j & 0x10) bytes = 3;
-	else if (~j & 0x08) bytes = 4;
-	else if (~j & 0x04) bytes = 5;
-	else if (~j & 0x02) bytes = 6;
-	else bytes = 1; /* This won't validate */
-
+	if ((j & 0xc0) && (~j & 0x20)) bytes = 2;
+	else if ((j & 0xe0) && (~j & 0x10)) bytes = 3;
+	else if ((j & 0xf0) && (~j & 0x08)) bytes = 4;
+	else if ((j & 0xf8) && (~j & 0x04)) bytes = 5;
+	else if ((j & 0xfc) && (~j & 0x02)) bytes = 6;
+	else bytes = 1;
+	
 	for (i = 1; i < bytes; i++) {
 	  utf8buf[i] = wgetch(typwin);
 	}


home help back first fref pref prev next nref lref last post