Created
August 23, 2008 10:55
-
-
Save ohac/6908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- taglib-1.5/taglib/toolkit/tstring.cpp.orig 2008-02-05 00:14:45.000000000 +0900 | |
+++ taglib-1.5/taglib/toolkit/tstring.cpp 2008-08-23 19:52:16.000000000 +0900 | |
@@ -208,12 +208,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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment