[MPlayer-cvslog] r23245 - in trunk: cfg-mplayer.h libmenu/menu.c

Benjamin Zores ben at geexbox.org
Sun May 20 01:51:38 CEST 2007


Rich Felker a écrit :
> On Thu, May 10, 2007 at 06:39:55PM +0200, Reimar Döffinger wrote:
>> Hello,
>> On Thu, May 10, 2007 at 11:05:12AM -0400, Rich Felker wrote:
>>> On Mon, May 07, 2007 at 06:33:30PM +0200, Reimar Döffinger wrote:
>>>> On Mon, May 07, 2007 at 05:55:59PM +0200, ben wrote:
>>>> [...]
>>>>> +static int get_next_char(char **txt)
>>>>> +{
>>>>> +  int c;
>>>>> +  c = (unsigned char)*(*txt)++;
>>>>> +  if (c >= 0x80) {
>>>>> +    if (menu_utf8){
>>>>> +      if ((c & 0xe0) == 0xc0)    /* 2 bytes U+00080..U+0007FF*/
>>>>> +        c = (c & 0x1f)<<6 | ((unsigned char)*(*txt)++ & 0x3f);
>>>>> +      else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/
>>>>> +        c = (((c & 0x0f)<<6) | ((unsigned char)*(*txt)++ & 0x3f))<<6;
>>>>> +        c |= ((unsigned char)*(*txt)++ & 0x3f);
>>>>> +      }
>>>>> +    } else if (menu_unicode)
>>>>> +      c = (c<<8) + (unsigned char)*(*txt)++;
>>>>> +  }
>>>>> +  if (!c) c++; // avoid UCS 0
>>>>> +  return c;
>>>> Please try to reuse utf8_get_char or libavutil GET_UTF8, this code is an
>>>> ugly mess and probably also less robust.
>>> Also this should not be a configure option, or at least the default
>>> should be taken from the system configuration. Having to manually
>>> "enable utf-8" in every application is utterly broken. Menu should use
>>> whatever the configured internal charset of MPlayer is.
>> To be honest I actually don't see what the point is in supporting
>> non-utf8 here...
> 
> I tend to agree. But whatever he does, FFS use either the MPlayer
> internal charset or UTF-8, and absolutely do not call UCS-2 "Unicode".
> Better would be not supporting UCS-2 at all since it's deprecated and
> cannot represent all of Unicode.

So what about simply replacing:

+static int get_next_char(char **txt)
+{
+  int c;
+  c = (unsigned char)*(*txt)++;
+  if (c >= 0x80) {
+    if (menu_utf8){
+      if ((c & 0xe0) == 0xc0)    /* 2 bytes U+00080..U+0007FF*/
+        c = (c & 0x1f)<<6 | ((unsigned char)*(*txt)++ & 0x3f);
+      else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/
+        c = (((c & 0x0f)<<6) | ((unsigned char)*(*txt)++ & 0x3f))<<6;
+        c |= ((unsigned char)*(*txt)++ & 0x3f);
+      }
+    } else if (menu_unicode)
+      c = (c<<8) + (unsigned char)*(*txt)++;
+  }
+  if (!c) c++; // avoid UCS 0
+  return c;
+}

by

+static int get_next_char(char **txt)
+{
+ return utf8_get_char((const char**)txt);
+}

getting, rid of -menu-utf8 and -menu-unicode.

Opinions ?

Ben




More information about the MPlayer-cvslog mailing list