summaryrefslogtreecommitdiffstats
path: root/fixes/taglib-fixes/taglib-1.4_wchar.diff
blob: b84a61401f74968f4c4d83005f393dbb66ae5bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff -ruN taglib-1.4.org/taglib/toolkit/tstring.cpp taglib-1.4/taglib/toolkit/tstring.cpp
--- taglib-1.4.org/taglib/toolkit/tstring.cpp	2005-07-26 06:31:15.000000000 +0900
+++ taglib-1.4/taglib/toolkit/tstring.cpp	2006-05-26 12:02:55.000000000 +0900
@@ -202,12 +202,22 @@
   s.resize(d->data.size());
 
   if(!unicode) {
-    std::string::iterator targetIt = s.begin();
-    for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
-      *targetIt = char(*it);
-      ++targetIt;
+    bool cjk = false;
+    //pre-scan: is there any cjk unicode character? if so, convert the string into utf-8.
+    for(unsigned int i=0; i< d->data.size(); i++){
+      if(d->data[i] > 0xff){
+        cjk = true;
+        break;
+      }
+    }
+    if(!cjk){
+      std::string::iterator targetIt = s.begin();
+      for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
+        *targetIt = char(*it);
+        ++targetIt;
+      }
+      return s;
     }
-    return s;
   }
 
   const int outputBufferSize = d->data.size() * 3 + 1;