[MPlayer-dev-eng] Re: [PATCH] OSD localization third try

Tobias Diedrich ranma at tdiedrich.de
Sun Nov 6 15:40:01 CET 2005


Paul TT wrote:

> > With --encoding=utf-8 I get garbage for non-ascii characters on the
> > OSD (looks like MPlayer's treating the string as iso-8859-1 anyway).
> > Probably there needs to be some charset dependend iconv conversion
> > in the OSD code.
> 
> i'm looking at it...

Well, semidirty fix attached.

-- 
Tobias						PGP: http://9ac7e0bc.uguu.de
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.1099
diff -u -r1.1099 configure
--- configure	5 Nov 2005 11:58:24 -0000	1.1099
+++ configure	6 Nov 2005 14:33:53 -0000
@@ -2403,6 +2403,16 @@
 done
 test -z "$_language" && _language=en
 _mp_help="help/help_mp-${_language}.h"
+_mp_help_charset="$_charset"
+test -z "$_mp_help_charset" -a \
+     -r "help/help_mp-${_language}.h.charset" && \
+     _mp_help_charset=`cat help/help_mp-${_language}.h.charset`
+_def_mp_help_charset="#define MP_HELP_CHARSET \"${_mp_help_charset-us-ascii}\""
+_def_mp_help_is_utf8="#define MP_HELP_IS_UTF8 0"
+_mp_help_charset_lowercase=`echo $_mp_help_charset | tr A-Z a-z`
+test "$_mp_help_charset_lowercase" = "utf-8" -o \
+     "$_mp_help_charset_lowercase" = "utf8" && \
+     _def_mp_help_is_utf8="#define MP_HELP_IS_UTF8 1"
 test -f $_mp_help || die "$_mp_help not found"
 for lang in $LANGUAGES ; do
   if test -f "DOCS/man/$lang/mplayer.1" ; then
@@ -7180,6 +7190,12 @@
 /* use GNU internationalization */
 $_def_i18n
 
+/* mp_help.h charset */
+$_def_mp_help_charset
+
+/* mp_help.h charset is utf-8 */
+$_def_mp_help_is_utf8
+
 /* Runtime CPU detection */
 $_def_runtime_cpudetection
 
Index: libvo/sub.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/sub.c,v
retrieving revision 1.81
diff -u -r1.81 sub.c
--- libvo/sub.c	23 Oct 2005 15:35:28 -0000	1.81
+++ libvo/sub.c	6 Nov 2005 14:33:53 -0000
@@ -150,6 +150,14 @@
 
         while (*cp){
           int c=*cp++;
+	  if (MP_HELP_IS_UTF8) {
+	    if ((c & 0xe0) == 0xc0 && *cp)    /* 2 bytes U+00080..U+0007FF*/
+	      c = (c & 0x1f)<<6 | (*cp++ & 0x3f);
+	    else if((c & 0xf0) == 0xe0 && *cp && *(cp+1)){ /* 3 bytes U+00800..U+00FFFF*/
+	      c = (((c & 0x0f)<<6) | (*cp++ & 0x3f))<<6;
+	      c |= (*cp++ & 0x3f);
+	    }
+	  }
 	  render_one_glyph(vo_font, c);
 	  x+=vo_font->width[c]+vo_font->charspace;
 	  h=get_height(c,h);
@@ -165,6 +173,14 @@
 	x = obj->x;
         while (*cp){
           int c=*cp++;
+	  if (MP_HELP_IS_UTF8) {
+	    if ((c & 0xe0) == 0xc0 && *cp)    /* 2 bytes U+00080..U+0007FF*/
+	      c = (c & 0x1f)<<6 | (*cp++ & 0x3f);
+	    else if((c & 0xf0) == 0xe0 && *cp && *(cp+1)){ /* 3 bytes U+00800..U+00FFFF*/
+	      c = (((c & 0x0f)<<6) | (*cp++ & 0x3f))<<6;
+	      c |= (*cp++ & 0x3f);
+	    }
+	  }
           if ((font=vo_font->font[c])>=0)
             draw_alpha_buf(obj,x,obj->y,
 			   vo_font->width[c],


More information about the MPlayer-dev-eng mailing list