Package: mpc
Version: 0.11.2-1

MPD gives report about songs tags in UTF8 charset. XTerm has KOI8-R locale.
Some symbols can not be converted from UTF8 to KOI8. For example -- '№'.
mpc use libiconv for character conversation.
Now, some tags, what have invalid (for a target charset) symbols, is not 
converted (by mpc) and displayed on KOI8-R terminal in native UTF8 coding (aka 
odd hieroglyphs for terminal users).
This is bug in charConv.c file.

First way for solving of the bug is to use libiconv IGNORE parameter for 
character set conversion setting like in iconv_prog.c (i.e. to emulate iconv -c 
parameter).
The patch for that way is attached. I have tested this patch on my system and 
mpc from now works good.

Second way (and better, I think), is to use librecord instead of libiconv.
For example:
   original text "Моцарт -- Симфония №40" ("Mozart - Symphony 
№40").
   iconv -c text "Моцарт -- Симфония 40" ("Mozart - Symphony 40").
   recode   text "Моцарт -- Симфония No40" ("Mozart - Symphony 
No40").
I believe, that replacing '№' to 'No' is definitely better than simply to 
drop that symbol from output.

--- mpc-0.11.2.orig/src/charConv.c      2005-03-11 12:04:35.000000000 +0300
+++ mpc-0.11.2/src/charConv.c   2005-06-15 13:07:29.917124224 +0400
@@ -45,6 +45,34 @@ char * char_conv_from = NULL;
 
 int setCharSetConversion(char * to, char * from) {
 #ifdef HAVE_ICONV
+       /* begin code from iconv_prog.c (omiting invalid symbols) */
+       const char *errhand = strchrnul (to, '/');
+       int nslash = 2;
+       char *newp;
+       char *cp;
+
+       if (*errhand == '/')
+       {
+               --nslash;
+               errhand = strchrnul (errhand, '/');
+
+               if (*errhand == '/')
+               {
+                       --nslash;
+                       ++errhand;
+               }
+       }
+
+       newp = (char *) alloca (errhand - to + nslash + 6 + 1);
+       cp = mempcpy (newp, to, errhand - to);
+       while (nslash-- > 0)
+               *cp++ = '/';
+       memcpy (cp, "IGNORE", sizeof ("IGNORE"));
+
+       to = newp;
+       /* end code from iconv_prog.c */
+       
+       
        if(char_conv_to && strcmp(to,char_conv_to)==0 &&
                        char_conv_from && strcmp(from,char_conv_from)==0)
        { 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to