2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
|
|
|
|
index e4a6d1f..324c502 100644
|
|
|
|
--- a/ConfigureChecks.cmake
|
|
|
|
+++ b/ConfigureChecks.cmake
|
|
|
|
@@ -14,6 +14,8 @@ else()
|
|
|
|
set(HAVE_ZLIB 0)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
+set(HAVE_LIBRCC 1)
|
|
|
|
+
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
|
|
|
find_package(CppUnit)
|
|
|
|
if(NOT CppUnit_FOUND AND BUILD_TESTS)
|
|
|
|
diff --git a/config-taglib.h.cmake b/config-taglib.h.cmake
|
|
|
|
index 9c2f487..8e445c7 100644
|
|
|
|
--- a/config-taglib.h.cmake
|
|
|
|
+++ b/config-taglib.h.cmake
|
|
|
|
@@ -3,6 +3,8 @@
|
2012-03-08 13:35:39 +01:00
|
|
|
/* Define if you have libz */
|
|
|
|
#cmakedefine HAVE_ZLIB 1
|
|
|
|
|
|
|
|
+#cmakedefine HAVE_LIBRCC 1
|
|
|
|
+
|
|
|
|
#cmakedefine NO_ITUNES_HACKS 1
|
|
|
|
#cmakedefine WITH_ASF 1
|
|
|
|
#cmakedefine WITH_MP4 1
|
2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt
|
|
|
|
index 61bcb49..49fbb62 100644
|
|
|
|
--- a/taglib/CMakeLists.txt
|
|
|
|
+++ b/taglib/CMakeLists.txt
|
|
|
|
@@ -35,6 +35,7 @@ set(tag_HDRS
|
|
|
|
audioproperties.h
|
|
|
|
taglib_export.h
|
|
|
|
${CMAKE_BINARY_DIR}/taglib_config.h
|
|
|
|
+ toolkit/rccpatch.h
|
|
|
|
toolkit/taglib.h
|
|
|
|
toolkit/tstring.h
|
|
|
|
toolkit/tlist.h
|
|
|
|
@@ -269,6 +270,7 @@ set(xm_SRCS
|
2012-03-08 13:35:39 +01:00
|
|
|
)
|
|
|
|
|
2012-09-17 11:49:04 +02:00
|
|
|
set(toolkit_SRCS
|
|
|
|
+ toolkit/rccpatch.cpp
|
|
|
|
toolkit/tstring.cpp
|
|
|
|
toolkit/tstringlist.cpp
|
|
|
|
toolkit/tbytevector.cpp
|
|
|
|
@@ -295,6 +297,8 @@ set(tag_LIB_SRCS
|
|
|
|
|
|
|
|
add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
|
2012-03-08 13:35:39 +01:00
|
|
|
|
2012-09-17 11:49:04 +02:00
|
|
|
+target_link_libraries(tag rcc)
|
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
if(ZLIB_FOUND)
|
2012-09-17 11:49:04 +02:00
|
|
|
target_link_libraries(tag ${ZLIB_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp
|
|
|
|
index e9eb47b..08650a1 100644
|
|
|
|
--- a/taglib/mpeg/id3v1/id3v1tag.cpp
|
|
|
|
+++ b/taglib/mpeg/id3v1/id3v1tag.cpp
|
|
|
|
@@ -64,17 +64,18 @@ StringHandler::StringHandler()
|
2012-03-08 13:35:39 +01:00
|
|
|
|
|
|
|
String ID3v1::StringHandler::parse(const ByteVector &data) const
|
|
|
|
{
|
|
|
|
- return String(data, String::Latin1).stripWhiteSpace();
|
|
|
|
+ return String(data, String::Latin1ID3).stripWhiteSpace();
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteVector ID3v1::StringHandler::render(const String &s) const
|
|
|
|
{
|
|
|
|
if(!s.isLatin1())
|
|
|
|
{
|
|
|
|
+ if (String::ID3WType(String::Latin1) == String::Latin1)
|
|
|
|
return ByteVector();
|
|
|
|
}
|
|
|
|
|
|
|
|
- return s.data(String::Latin1);
|
|
|
|
+ return s.data(String::Latin1ID3);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -247,7 +248,7 @@ void ID3v1::Tag::parse(const ByteVector &data)
|
2012-03-08 13:35:39 +01:00
|
|
|
d->track = uchar(data[offset + 29]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
- d->comment = data.mid(offset, 30);
|
|
|
|
+ d->comment = TagPrivate::stringHandler->parse(data.mid(offset, 30));
|
|
|
|
|
|
|
|
offset += 30;
|
|
|
|
|
2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/taglib/mpeg/id3v2/frames/commentsframe.cpp b/taglib/mpeg/id3v2/frames/commentsframe.cpp
|
|
|
|
index deaa9d9..9d0df07 100644
|
|
|
|
--- a/taglib/mpeg/id3v2/frames/commentsframe.cpp
|
|
|
|
+++ b/taglib/mpeg/id3v2/frames/commentsframe.cpp
|
|
|
|
@@ -150,10 +150,10 @@ void CommentsFrame::parseFields(const ByteVector &data)
|
2012-03-08 13:35:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- d->textEncoding = String::Type(data[0]);
|
|
|
|
+ d->textEncoding = String::ID3Type(data[0]);
|
|
|
|
d->language = data.mid(1, 3);
|
|
|
|
|
|
|
|
- int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
|
|
|
|
+ int byteAlign = d->textEncoding == (String::Latin1 || String::Latin1ID3 || String::Latin1ID3V2 || d->textEncoding == String::UTF8) ? 1 : 2;
|
|
|
|
|
|
|
|
ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
|
|
|
|
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -174,10 +174,12 @@ ByteVector CommentsFrame::renderFields() const
|
2012-03-08 13:35:39 +01:00
|
|
|
|
|
|
|
String::Type encoding = d->textEncoding;
|
|
|
|
|
|
|
|
+ encoding = String::ID3WType(encoding);
|
|
|
|
+
|
2012-09-17 11:49:04 +02:00
|
|
|
encoding = checkTextEncoding(d->description, encoding);
|
|
|
|
encoding = checkTextEncoding(d->text, encoding);
|
|
|
|
|
2012-03-08 13:35:39 +01:00
|
|
|
- v.append(char(encoding));
|
|
|
|
+ v.append(char(String::ID3RealType(encoding)));
|
|
|
|
v.append(d->language.size() == 3 ? d->language : "XXX");
|
|
|
|
v.append(d->description.data(encoding));
|
|
|
|
v.append(textDelimiter(encoding));
|
2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/taglib/toolkit/rccpatch.cpp b/taglib/toolkit/rccpatch.cpp
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..eadbcb1
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/taglib/toolkit/rccpatch.cpp
|
2012-03-08 13:35:39 +01:00
|
|
|
@@ -0,0 +1,198 @@
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+
|
|
|
|
+#include <string>
|
|
|
|
+#include "tstring.h"
|
|
|
|
+#include "tbytevector.h"
|
|
|
|
+
|
|
|
|
+#ifndef HAVE_LIBRCC
|
|
|
|
+# include <config.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+# include <librcc.h>
|
|
|
|
+# include <string.h>
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+# define ID3_CLASS 0
|
|
|
|
+# define ID3V2_CLASS 1
|
|
|
|
+# define UTF_CLASS 2
|
|
|
|
+# define OUT_CLASS 3
|
|
|
|
+static rcc_class classes[] = {
|
|
|
|
+ { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
|
|
|
|
+ { "id3v2", RCC_CLASS_STANDARD, "id3", NULL, "ID3 v.2 Encoding", 0 },
|
|
|
|
+ { "utf", RCC_CLASS_KNOWN, "UTF-8", NULL, "Unicode Encoding", 0},
|
|
|
|
+ { "out", RCC_CLASS_TRANSLATE_LOCALE, "LC_CTYPE", NULL, "Output Encoding", 0 },
|
|
|
|
+ { NULL, RCC_CLASS_STANDARD, NULL, NULL, NULL, 0 }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static int rcc_initialized = 0;
|
|
|
|
+
|
|
|
|
+static rcc_context ctx = NULL;
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void rccPatchFree() {
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ if (rcc_initialized) {
|
|
|
|
+ rccFree();
|
|
|
|
+ rcc_initialized = 0;
|
|
|
|
+ }
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void rccPatchInit() {
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ if (rcc_initialized) return;
|
|
|
|
+ rccInit();
|
|
|
|
+ rccInitDefaultContext(NULL, 0, 0, classes, 0);
|
|
|
|
+ rccLoad(NULL, "xmms");
|
|
|
|
+ rccInitDb4(NULL, NULL, 0);
|
|
|
|
+ rcc_initialized = 1;
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void rccPatchSetContext(void *newctx) {
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ if (newctx) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ ctx = (rcc_context)newctx;
|
|
|
|
+ rcc_initialized = 1;
|
2012-03-08 13:35:39 +01:00
|
|
|
+ }
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void rccPatchTryInit() {
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ if (!rcc_initialized) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ rccPatchInit();
|
|
|
|
+ if (rcc_initialized) atexit(rccPatchFree);
|
2012-03-08 13:35:39 +01:00
|
|
|
+ }
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+TagLib::ByteVector rccPatchRecodeOutput(const std::string &s) {
|
|
|
|
+ TagLib::ByteVector v;
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ size_t rlen;
|
|
|
|
+ char *res;
|
|
|
|
+
|
|
|
|
+ rccPatchTryInit();
|
|
|
|
+
|
|
|
|
+ res = rccSizedRecode(ctx, UTF_CLASS, OUT_CLASS, s.c_str(), s.length(), &rlen);
|
|
|
|
+ if (res) v.setData(res, rlen);
|
|
|
|
+ else v.setData(s.c_str(), s.length());
|
|
|
|
+
|
|
|
|
+ return v;
|
|
|
|
+#else
|
|
|
|
+ v.setData("", 0);
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ return v;
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TagLib::ByteVector rccPatchRecodeOutputID3(const std::string &s, bool v2 = false) {
|
|
|
|
+ TagLib::ByteVector v;
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ size_t rlen;
|
|
|
|
+ char *res;
|
|
|
|
+
|
|
|
|
+ rccPatchTryInit();
|
|
|
|
+
|
|
|
|
+ res = rccSizedRecode(ctx, UTF_CLASS, v2?ID3V2_CLASS:ID3_CLASS, s.c_str(), s.length(), &rlen);
|
|
|
|
+ if (res) v.setData(res, rlen);
|
|
|
|
+ else v.setData(s.c_str(), s.length());
|
|
|
|
+
|
|
|
|
+ return v;
|
|
|
|
+#else
|
|
|
|
+ v.setData("", 0);
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ return v;
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TagLib::ByteVector rccPatchRecodeInput(const std::string &s) {
|
|
|
|
+ TagLib::ByteVector v;
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ size_t rlen;
|
|
|
|
+ char *res;
|
|
|
|
+
|
|
|
|
+ rccPatchTryInit();
|
|
|
|
+
|
|
|
|
+ res = rccSizedRecode(ctx, OUT_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
|
|
|
|
+ if (res) v.setData(res, rlen);
|
|
|
|
+ else v.setData(s.c_str(), s.length());
|
|
|
|
+
|
|
|
|
+ return v;
|
|
|
|
+#else
|
|
|
|
+ v.setData("", 0);
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ return v;
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TagLib::ByteVector rccPatchRecodeInputID3(const std::string &s, bool v2 = false) {
|
|
|
|
+ TagLib::ByteVector v;
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ size_t rlen;
|
|
|
|
+ char *res;
|
|
|
|
+
|
|
|
|
+ rccPatchTryInit();
|
|
|
|
+
|
|
|
|
+ res = rccSizedRecode(ctx, v2?ID3V2_CLASS:ID3_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
|
|
|
|
+ if (res) v.setData(res, rlen);
|
|
|
|
+ else v.setData(s.c_str(), s.length());
|
|
|
|
+
|
|
|
|
+ return v;
|
|
|
|
+#else
|
|
|
|
+ v.setData("", 0);
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ return v;
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TagLib::String::Type rccPatchGetLocaleType() {
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ size_t len;
|
|
|
|
+ char charset[32];
|
|
|
|
+
|
|
|
|
+ rccPatchTryInit();
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ if (!rccLocaleGetCharset(charset, NULL, 31)) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ if (!strncmp(charset, "UTF", 3)) {
|
|
|
|
+ len = strlen(charset);
|
|
|
|
+
|
|
|
|
+ if (charset[len-1]=='8') return TagLib::String::UTF8;
|
|
|
|
+ if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
|
|
|
|
+ if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
|
|
|
|
+ if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
|
|
|
|
+ }
|
|
|
|
+ return TagLib::String::Latin1;
|
2012-03-08 13:35:39 +01:00
|
|
|
+ }
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+ return TagLib::String::UTF8;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TagLib::String::Type rccPatchGetID3Type() {
|
|
|
|
+#ifdef HAVE_LIBRCC
|
|
|
|
+ size_t len;
|
|
|
|
+ const char *charset;
|
|
|
|
+
|
|
|
|
+ rccPatchTryInit();
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ charset = rccGetCurrentCharsetName(ctx, ID3V2_CLASS);
|
|
|
|
+ if (charset) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ if (!strncmp(charset, "UTF", 3)) {
|
|
|
|
+ len = strlen(charset);
|
|
|
|
+
|
|
|
|
+ if (charset[len-1]=='8') return TagLib::String::UTF8;
|
|
|
|
+ if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
|
|
|
|
+ if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
|
|
|
|
+ if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
|
|
|
|
+ }
|
|
|
|
+ return TagLib::String::Latin1ID3V2;
|
2012-03-08 13:35:39 +01:00
|
|
|
+ }
|
|
|
|
+#endif /* HAVE_LIBRCC */
|
|
|
|
+ return TagLib::String::Latin1;
|
|
|
|
+}
|
2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/taglib/toolkit/rccpatch.h b/taglib/toolkit/rccpatch.h
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..9484a93
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/taglib/toolkit/rccpatch.h
|
2012-03-08 13:35:39 +01:00
|
|
|
@@ -0,0 +1,20 @@
|
|
|
|
+#ifndef _RCC_PATCH_H
|
|
|
|
+#define _RCC_PATCH_H
|
|
|
|
+
|
|
|
|
+#include <string.h>
|
|
|
|
+#include "tstring.h"
|
|
|
|
+#include "tbytevector.h"
|
|
|
|
+
|
|
|
|
+void rccPatchFree();
|
|
|
|
+void rccPatchInit();
|
|
|
|
+void rccPatchSetContext(void *newctx);
|
|
|
|
+
|
|
|
|
+TagLib::ByteVector rccPatchRecodeOutput(const std::string &s);
|
|
|
|
+TagLib::ByteVector rccPatchRecodeInput(const std::string &s);
|
|
|
|
+TagLib::ByteVector rccPatchRecodeOutputID3(const std::string &s, bool v2 = false);
|
|
|
|
+TagLib::ByteVector rccPatchRecodeInputID3(const std::string &s, bool v2 = false);
|
|
|
|
+
|
|
|
|
+TagLib::String::Type rccPatchGetLocaleType();
|
|
|
|
+TagLib::String::Type rccPatchGetID3Type();
|
|
|
|
+
|
|
|
|
+#endif /* _RCC_PATCH_H */
|
2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp
|
|
|
|
index 292f353..45b7d03 100644
|
|
|
|
--- a/taglib/toolkit/tstring.cpp
|
|
|
|
+++ b/taglib/toolkit/tstring.cpp
|
2012-03-08 13:35:39 +01:00
|
|
|
@@ -23,6 +23,7 @@
|
|
|
|
* http://www.mozilla.org/MPL/ *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
+#include "rccpatch.h"
|
|
|
|
#include "tstring.h"
|
|
|
|
#include "unicode.h"
|
|
|
|
#include "tdebug.h"
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -168,7 +169,7 @@ String::String(const ByteVector &v, Type t)
|
2012-03-08 13:35:39 +01:00
|
|
|
if(v.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
- if(t == Latin1 || t == UTF8) {
|
|
|
|
+ if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2 || t == UTF8) {
|
|
|
|
|
|
|
|
int length = 0;
|
|
|
|
d->data.resize(v.size());
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -397,10 +398,21 @@ ByteVector String::data(Type t) const
|
2012-03-08 13:35:39 +01:00
|
|
|
{
|
|
|
|
ByteVector v;
|
|
|
|
|
|
|
|
- switch(t) {
|
|
|
|
+ if (t == Locale) t = rccPatchGetLocaleType();
|
|
|
|
|
|
|
|
+ switch(t) {
|
|
|
|
+ case Locale:
|
|
|
|
case Latin1:
|
|
|
|
+ case Latin1ID3:
|
|
|
|
+ case Latin1ID3V2:
|
|
|
|
{
|
|
|
|
+ std::string s = to8Bit(true);
|
|
|
|
+ if (t == Latin1ID3) v = rccPatchRecodeOutputID3(s, false);
|
|
|
|
+ else if (t == Latin1ID3V2) v = rccPatchRecodeOutputID3(s, true);
|
|
|
|
+ else /* if (t == Latin1(Locale) */ v = rccPatchRecodeOutput(s);
|
|
|
|
+
|
|
|
|
+ if (v.size()) return v;
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
|
|
|
|
v.append(char(*it));
|
|
|
|
break;
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -750,6 +762,31 @@ void String::detach()
|
2012-03-08 13:35:39 +01:00
|
|
|
|
|
|
|
void String::prepare(Type t)
|
|
|
|
{
|
|
|
|
+ if (t == Locale) t = rccPatchGetLocaleType();
|
|
|
|
+
|
|
|
|
+ if ((t == Latin1)||(t == Latin1ID3)||(t == Latin1ID3V2)) {
|
|
|
|
+ std::string s = to8Bit(false);
|
|
|
|
+ ByteVector v;
|
|
|
|
+
|
|
|
|
+ if (t == Latin1ID3) v = rccPatchRecodeInputID3(s, false);
|
|
|
|
+ else if (t == Latin1ID3V2) v = rccPatchRecodeInputID3(s, true);
|
|
|
|
+ else /* Latin1 converted from Locale */ v = rccPatchRecodeInput(s);
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ if (v.size()) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ int length = 0;
|
|
|
|
+ d->data.resize(v.size());
|
|
|
|
+ wstring::iterator targetIt = d->data.begin();
|
|
|
|
+ for(ByteVector::ConstIterator it = v.begin(); it != v.end() && (*it); ++it) {
|
|
|
|
+ *targetIt = uchar(*it);
|
|
|
|
+ ++targetIt;
|
|
|
|
+ ++length;
|
|
|
|
+ }
|
|
|
|
+ d->data.resize(length);
|
2012-03-08 13:35:39 +01:00
|
|
|
+ }
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ t = UTF8;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
switch(t) {
|
|
|
|
case UTF16:
|
|
|
|
{
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -839,6 +876,27 @@ const TagLib::String operator+(const TagLib::String &s1, const char *s2)
|
2012-03-08 13:35:39 +01:00
|
|
|
|
|
|
|
std::ostream &operator<<(std::ostream &s, const String &str)
|
|
|
|
{
|
|
|
|
- s << str.to8Bit();
|
|
|
|
+ ByteVector bv = str.data(String::Locale);
|
|
|
|
+ s << bv;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+String::Type String::ID3Type(int i) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ if (i == Latin1) return Latin1ID3V2;
|
|
|
|
+ return Type(i);
|
2012-03-08 13:35:39 +01:00
|
|
|
+};
|
|
|
|
+
|
|
|
|
+String::Type String::ID3WType(Type type) {
|
|
|
|
+ Type rcc_type = rccPatchGetID3Type();
|
|
|
|
+ if ((rcc_type == Latin1ID3)||(rcc_type == Latin1ID3V2)) {
|
2012-09-17 11:49:04 +02:00
|
|
|
+ if (type == Latin1) return rcc_type;
|
|
|
|
+ return type;
|
2012-03-08 13:35:39 +01:00
|
|
|
+ }
|
2012-09-17 11:49:04 +02:00
|
|
|
+
|
2012-03-08 13:35:39 +01:00
|
|
|
+ return rcc_type;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+String::Type String::ID3RealType(Type type) {
|
|
|
|
+ if ((type == Latin1ID3)||(type == Latin1ID3V2)) return Latin1;
|
|
|
|
+ return type;
|
|
|
|
+}
|
2012-09-17 11:49:04 +02:00
|
|
|
diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h
|
|
|
|
index 759a175..af38090 100644
|
|
|
|
--- a/taglib/toolkit/tstring.h
|
|
|
|
+++ b/taglib/toolkit/tstring.h
|
|
|
|
@@ -90,6 +90,18 @@ namespace TagLib {
|
2012-03-08 13:35:39 +01:00
|
|
|
*/
|
|
|
|
enum Type {
|
|
|
|
/*!
|
|
|
|
+ * Determine using current locale settings
|
|
|
|
+ */
|
|
|
|
+ Locale = -1,
|
|
|
|
+ /*!
|
|
|
|
+ * Latin1 for ID3 tags.
|
|
|
|
+ */
|
|
|
|
+ Latin1ID3 = 65,
|
|
|
|
+ /*!
|
|
|
|
+ * Latin1 for ID3 tags.
|
|
|
|
+ */
|
|
|
|
+ Latin1ID3V2 = 66,
|
|
|
|
+ /*!
|
|
|
|
* IS08859-1, or <i>Latin1</i> encoding. 8 bit characters.
|
|
|
|
*/
|
|
|
|
Latin1 = 0,
|
2012-09-17 11:49:04 +02:00
|
|
|
@@ -112,6 +124,10 @@ namespace TagLib {
|
2012-03-08 13:35:39 +01:00
|
|
|
UTF16LE = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
+ static Type ID3Type(int i);
|
|
|
|
+ static Type ID3WType(Type type);
|
|
|
|
+ static Type ID3RealType(Type type);
|
|
|
|
+
|
|
|
|
/*!
|
|
|
|
* Constructs an empty String.
|
|
|
|
*/
|