Re: [dev] Re: [st] multibyte patch

From: Damian Okrasa <dokrasa_AT_gmail.com>
Date: Sat, 20 Nov 2010 17:56:17 +0100

2010/11/19, Hiltjo Posthuma <hiltjo_AT_codemadness.org>:
> I noticed in canstou():
>
> 329 /* use this if your buffer is less than UTF_SIZ, it returns 1
> if you can decode
> 330 UTF-8 otherwise return 0 */
> 331 static int canstou(char *s, int b) {
> 332 unsigned char c = *s;
> 333 int n;
> 334
> 335 if (b < 1)
> 336 return 0;
> 337 else if (~c&B7)
> 338 return 1;
> 339 else if ((c&(B7|B6|B5)) == (B7|B6))
> 340 n = 1;
> 341 else if ((c&(B7|B6|B5|B4)) == (B7|B6|B5))
> 342 n = 2;
> 343 else if ((c&(B7|B6|B5|B4|B3)) == (B7|B6|B5|B4))
> 344 n = 3;
> 345 else
> 346 return 1;
>
> |
> v this is never reached.
> 347 for (--b,++s; n>0&&b>0; --n,--b,++s) {
> 348 c = *s;
> 349 if ((c&(B7|B6)) != B7)
> 350 break;
> 351 }
> 352 if (n > 0 && b == 0)
> 353 return 0;
> 354 else
> 355 return 1;
> 356 }
>

it' reached when
b >= 1 and first byte of s is 110xxxxx or 1110xxxx or 111110xxx

I've attached changed version, it looks simpler. There are some other
changes too, font loading code. I'm not sure if the line drawing is
needed in xdraws() since unicode has some box drawing characters.

Received on Sat Nov 20 2010 - 17:56:17 CET

This archive was generated by hypermail 2.2.0 : Sat Nov 20 2010 - 18:00:05 CET