comparison libmenu/menu.c @ 23232:c5ac43d53bb1

use already existing function to get utf8 char in libmenu (thx to reimar)
author ben
date Mon, 07 May 2007 17:02:42 +0000
parents ab87f5488c7d
children c2557e82803b
comparison
equal deleted inserted replaced
23231:ab87f5488c7d 23232:c5ac43d53bb1
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include "libvo/osd.h" 12 #include "libvo/osd.h"
13 #include "libvo/font_load.h" 13 #include "libvo/font_load.h"
14 #include "libvo/sub.h"
14 #include "osdep/keycodes.h" 15 #include "osdep/keycodes.h"
15 #include "asxparser.h" 16 #include "asxparser.h"
16 #include "stream/stream.h" 17 #include "stream/stream.h"
17 18
18 #include "libmpcodecs/img_format.h" 19 #include "libmpcodecs/img_format.h"
302 static int get_next_char(char **txt) 303 static int get_next_char(char **txt)
303 { 304 {
304 int c; 305 int c;
305 c = (unsigned char)*(*txt)++; 306 c = (unsigned char)*(*txt)++;
306 if (c >= 0x80) { 307 if (c >= 0x80) {
307 if (menu_utf8){ 308 if (menu_utf8)
308 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/ 309 c = utf8_get_char((const char*)txt);
309 c = (c & 0x1f)<<6 | ((unsigned char)*(*txt)++ & 0x3f); 310 else if (menu_unicode)
310 else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/
311 c = (((c & 0x0f)<<6) | ((unsigned char)*(*txt)++ & 0x3f))<<6;
312 c |= ((unsigned char)*(*txt)++ & 0x3f);
313 }
314 } else if (menu_unicode)
315 c = (c<<8) + (unsigned char)*(*txt)++; 311 c = (c<<8) + (unsigned char)*(*txt)++;
316 } 312 }
317 if (!c) c++; // avoid UCS 0 313 if (!c) c++; // avoid UCS 0
318 return c; 314 return c;
319 } 315 }