# HG changeset patch # User yaz # Date 1150985065 25200 # Node ID 99454d03072271e9ff65003dcd2a71cd0de92579 # Parent 43547cd5e74e6800eb3c7a215c8fd8d3e6f4f622 [svn] try to avoid malconversion of latin1 character when chardet has been enabled. diff -r 43547cd5e74e -r 99454d030722 ChangeLog --- a/ChangeLog Thu Jun 22 03:01:46 2006 -0700 +++ b/ChangeLog Thu Jun 22 07:04:25 2006 -0700 @@ -1,3 +1,12 @@ +2006-06-22 10:01:46 +0000 William Pitcock + revision [1558] + - smarter way to detect gmake + + + Changes: Modified: + +1 -1 trunk/mk/objective.mk + + 2006-06-22 09:35:01 +0000 William Pitcock revision [1556] - avoid system /bin/test in Makefiles as it may not behave as expected diff -r 43547cd5e74e -r 99454d030722 audacious/util.c --- a/audacious/util.c Thu Jun 22 03:01:46 2006 -0700 +++ b/audacious/util.c Thu Jun 22 07:04:25 2006 -0700 @@ -1279,14 +1279,22 @@ if (!str) return NULL; + /* Note: Currently, playlist calls this function repeatedly, even + * if the string is already converted into utf-8. + * chardet_to_utf8() would convert a valid utf-8 string into a + * different utf-8 string, if fallback encodings were supplied and + * the given string could be treated as a string in one of fallback + * encodings. To avoid this, the order of evaluation has been + * changed. (It might cause a drawback?) + */ + /* already UTF-8? */ + if (g_utf8_validate(str, -1, NULL)) + return g_strdup(str); + /* chardet encoding detector */ if ((out_str = chardet_to_utf8(str, strlen(str), NULL, NULL, NULL))) return out_str; - /* already UTF-8? */ - if (g_utf8_validate(str, -1, NULL)) - return g_strdup(str); - /* assume encoding associated with locale */ if ((out_str = g_locale_to_utf8(str, -1, NULL, NULL, NULL))) return out_str; @@ -1491,6 +1499,16 @@ } } +#ifdef USE_CHARDET + /* many tag libraries return 2byte latin1 utf8 character as + converted 8bit iso-8859-1 character, if they are asked to return + latin1 string. + */ + if(!ret){ + ret = g_convert(str, len, "UTF-8", "ISO-8859-1", bytes_read, bytes_write, error); + } +#endif + if(ret){ if(g_utf8_validate(ret, -1, NULL)) return ret; @@ -1500,5 +1518,5 @@ } } - return NULL; // if I have no idea, return NULL. + return NULL; /* if I have no idea, return NULL. */ }