View | Details | Raw Unified | Return to bug 246025
Collapse All | Expand All

(-)audio/taglib/Makefile (-11 / +12 lines)
Lines 2-11 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	taglib
4
PORTNAME=	taglib
5
PORTVERSION=	1.11.1
5
DISTVERSIONPREFIX=	v
6
PORTREVISION=	3
6
DISTVERSION=	1.12-beta-1
7
CATEGORIES=	audio
7
CATEGORIES=	audio
8
MASTER_SITES=	https://taglib.github.io/releases/
9
8
10
MAINTAINER=	jhale@FreeBSD.org
9
MAINTAINER=	jhale@FreeBSD.org
11
COMMENT=	Library for manipulating ID3 tags and Ogg comments
10
COMMENT=	Library for manipulating ID3 tags and Ogg comments
Lines 15-38 Link Here
15
LICENSE_FILE_LGPL21=	${WRKSRC}/COPYING.LGPL
14
LICENSE_FILE_LGPL21=	${WRKSRC}/COPYING.LGPL
16
LICENSE_FILE_MPL11=	${WRKSRC}/COPYING.MPL
15
LICENSE_FILE_MPL11=	${WRKSRC}/COPYING.MPL
17
16
17
TEST_DEPENDS=	cppunit-config:devel/cppunit
18
18
USES=		cmake compiler:c++11-lang cpe pathfix
19
USES=		cmake compiler:c++11-lang cpe pathfix
19
USE_LDCONFIG=	yes
20
USE_LDCONFIG=	yes
20
21
22
USE_GITHUB=	yes
23
21
CMAKE_ON=	CMAKE_DISABLE_FIND_PACKAGE_Boost \
24
CMAKE_ON=	CMAKE_DISABLE_FIND_PACKAGE_Boost \
22
		WITH_ASF \
25
		WITH_ASF \
23
		WITH_MP4 \
26
		WITH_MP4
24
		BUILD_SHARED_LIBS
25
27
26
CPE_VENDOR=	scott_wheeler
28
OPTIONS_DEFINE=	RCC TEST
27
28
OPTIONS_DEFINE=	RCC
29
OPTIONS_SUB=	yes
29
OPTIONS_SUB=	yes
30
30
31
# The official patches for this can be obtained from:
31
# The official patches for this can be obtained from:
32
#   http://darksoft.org/files/rusxmms/patches/
32
#   http://darksoft.org/files/rusxmms/patches/
33
# however, they do not seem to yet have any for taglib-1.11.1.
34
# So instead, use:
35
#   https://sourceforge.net/p/qmmp-dev/code/HEAD/tree/trunk/extras/package/win32/contrib/taglib-rusxmms/
36
#
33
#
37
RCC_DESC=		Build with RusXMMS librcc patches (experimental)
34
RCC_DESC=		Build with RusXMMS librcc patches (experimental)
38
RCC_LIB_DEPENDS=	librcc.so:devel/librcc
35
RCC_LIB_DEPENDS=	librcc.so:devel/librcc
Lines 39-44 Link Here
39
RCC_USES=		localbase:ldflags
36
RCC_USES=		localbase:ldflags
40
RCC_EXTRA_PATCHES=	${FILESDIR}/extrapatch-rcc
37
RCC_EXTRA_PATCHES=	${FILESDIR}/extrapatch-rcc
41
38
39
TEST_CMAKE_BOOL=	BUILD_TESTS
40
TEST_CMAKE_BOOL_OFF=	BUILD_SHARED_LIBS
41
TEST_TARGET=	check
42
42
post-patch-RCC-on:
43
post-patch-RCC-on:
43
	@${REINPLACE_CMD} -e 's|-ltag|-ltag -lrcc|g' \
44
	@${REINPLACE_CMD} -e 's|-ltag|-ltag -lrcc|g' \
44
		${WRKSRC}/taglib.pc.cmake ${WRKSRC}/taglib-config.cmake
45
		${WRKSRC}/taglib.pc.cmake ${WRKSRC}/taglib-config.cmake
(-)audio/taglib/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1501054372
1
TIMESTAMP = 1588158265
2
SHA256 (taglib-1.11.1.tar.gz) = b6d1a5a610aae6ff39d93de5efd0fdc787aa9e9dc1e7026fa4c961b26563526b
2
SHA256 (taglib-taglib-v1.12-beta-1_GH0.tar.gz) = d2a44be7ca8b7682b218affc9910dcfb027481f402f7c30bd2996392b2429ae4
3
SIZE (taglib-1.11.1.tar.gz) = 1261620
3
SIZE (taglib-taglib-v1.12-beta-1_GH0.tar.gz) = 1289326
(-)audio/taglib/files/extrapatch-rcc (-126 / +149 lines)
Lines 1-24 Link Here
1
Obtained from:
1
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
2
	https://sourceforge.net/p/qmmp-dev/code/HEAD/tree/trunk/extras/package/win32/contrib/taglib-rusxmms/taglib-1.11.1-ds-rusxmms.patch?format=raw
2
index 5e5fca2..69a5e39 100644
3
3
--- ConfigureChecks.cmake
4
diff --git CMakeLists.txt CMakeLists.txt
4
+++ ConfigureChecks.cmake
5
index a59efc9..eda2f53 100644
5
@@ -213,3 +213,5 @@ endif()
6
--- CMakeLists.txt
6
 if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
7
+++ CMakeLists.txt
7
 	set(PLATFORM WINRT 1)
8
@@ -120,6 +120,8 @@ if(NOT HAVE_ZLIB AND ZLIB_SOURCE)
9
   set(HAVE_ZLIB_SOURCE 1)
10
 endif()
8
 endif()
11
 
9
+
12
+SET(HAVE_LIBRCC 1)
10
+SET(HAVE_LIBRCC 1)
13
+
11
\ No newline at end of file
14
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
12
diff --git a/config.h.cmake b/config.h.cmake
15
 configure_file(config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/config.h")
13
index c1a3109..5eb5b84 100644
16
 
17
diff --git config.h.cmake config.h.cmake
18
index 7eb5993..8d4a541 100644
19
--- config.h.cmake
14
--- config.h.cmake
20
+++ config.h.cmake
15
+++ config.h.cmake
21
@@ -30,4 +30,7 @@
16
@@ -30,6 +30,9 @@
22
 /* Indicates whether debug messages are shown even in release mode */
17
 /* Indicates whether debug messages are shown even in release mode */
23
 #cmakedefine   TRACE_IN_RELEASE 1
18
 #cmakedefine   TRACE_IN_RELEASE 1
24
 
19
 
Lines 26-32 Link Here
26
+#cmakedefine   HAVE_LIBRCC 1
21
+#cmakedefine   HAVE_LIBRCC 1
27
+
22
+
28
 #cmakedefine TESTS_DIR "@TESTS_DIR@"
23
 #cmakedefine TESTS_DIR "@TESTS_DIR@"
29
diff --git examples/tagreader_c.c examples/tagreader_c.c
24
 
25
 #endif
26
diff --git a/examples/tagreader_c.c b/examples/tagreader_c.c
30
index 0436992..e0f17d8 100644
27
index 0436992..e0f17d8 100644
31
--- examples/tagreader_c.c
28
--- examples/tagreader_c.c
32
+++ examples/tagreader_c.c
29
+++ examples/tagreader_c.c
Lines 39-45 Link Here
39
 
36
 
40
   for(i = 1; i < argc; i++) {
37
   for(i = 1; i < argc; i++) {
41
     printf("******************** \"%s\" ********************\n", argv[i]);
38
     printf("******************** \"%s\" ********************\n", argv[i]);
42
diff --git examples/tagwriter.cpp examples/tagwriter.cpp
39
diff --git a/examples/tagwriter.cpp b/examples/tagwriter.cpp
43
index ed8b0d7..6a7a263 100644
40
index ed8b0d7..6a7a263 100644
44
--- examples/tagwriter.cpp
41
--- examples/tagwriter.cpp
45
+++ examples/tagwriter.cpp
42
+++ examples/tagwriter.cpp
Lines 52-62 Link Here
52
 
49
 
53
       TagLib::List<TagLib::FileRef>::ConstIterator it;
50
       TagLib::List<TagLib::FileRef>::ConstIterator it;
54
       for(it = fileList.begin(); it != fileList.end(); ++it) {
51
       for(it = fileList.begin(); it != fileList.end(); ++it) {
55
diff --git taglib/CMakeLists.txt taglib/CMakeLists.txt
52
diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt
56
index 000f793..e30471e 100644
53
index fcff0b3..2741ef4 100644
57
--- taglib/CMakeLists.txt
54
--- taglib/CMakeLists.txt
58
+++ taglib/CMakeLists.txt
55
+++ taglib/CMakeLists.txt
59
@@ -42,6 +42,7 @@ set(tag_HDRS
56
@@ -41,6 +41,7 @@ set(tag_HDRS
60
   audioproperties.h
57
   audioproperties.h
61
   taglib_export.h
58
   taglib_export.h
62
   ${CMAKE_CURRENT_BINARY_DIR}/../taglib_config.h
59
   ${CMAKE_CURRENT_BINARY_DIR}/../taglib_config.h
Lines 72-91 Link Here
72
   toolkit/tstring.cpp
69
   toolkit/tstring.cpp
73
   toolkit/tstringlist.cpp
70
   toolkit/tstringlist.cpp
74
   toolkit/tbytevector.cpp
71
   toolkit/tbytevector.cpp
75
@@ -345,7 +347,7 @@ set(tag_LIB_SRCS
72
@@ -339,7 +341,9 @@ set(tag_LIB_SRCS
76
 add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
73
 add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
77
 
74
 
78
 if(ZLIB_FOUND)
75
 if(HAVE_ZLIB AND NOT HAVE_ZLIB_SOURCE)
79
-  target_link_libraries(tag ${ZLIB_LIBRARIES})
76
-  target_link_libraries(tag ${ZLIB_LIBRARIES})
80
+  target_link_libraries(tag rcc ${ZLIB_LIBRARIES})
77
+  target_link_libraries(tag rcc ${ZLIB_LIBRARIES})
78
+else ()
79
+  target_link_libraries(tag rcc)
81
 endif()
80
 endif()
82
 
81
 
83
 if(HAVE_BOOST_ATOMIC)
82
 set_target_properties(tag PROPERTIES
84
diff --git taglib/mpeg/id3v1/id3v1tag.cpp taglib/mpeg/id3v1/id3v1tag.cpp
83
diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp
85
index ca93041..dca5f7a 100644
84
index ca93041..872ba6a 100644
86
--- taglib/mpeg/id3v1/id3v1tag.cpp
85
--- taglib/mpeg/id3v1/id3v1tag.cpp
87
+++ taglib/mpeg/id3v1/id3v1tag.cpp
86
+++ taglib/mpeg/id3v1/id3v1tag.cpp
88
@@ -69,15 +69,15 @@ StringHandler::StringHandler()
87
@@ -69,15 +69,18 @@ StringHandler::StringHandler()
89
 
88
 
90
 String ID3v1::StringHandler::parse(const ByteVector &data) const
89
 String ID3v1::StringHandler::parse(const ByteVector &data) const
91
 {
90
 {
Lines 98-111 Link Here
98
-  if(s.isLatin1())
97
-  if(s.isLatin1())
99
-    return s.data(String::Latin1);
98
-    return s.data(String::Latin1);
100
-  else
99
-  else
101
+  if(!s.isLatin1() && String::ID3WType(String::Latin1) == String::Latin1)
100
+  if(!s.isLatin1())
101
+  {
102
+   if (String::ID3WType(String::Latin1) == String::Latin1)
102
     return ByteVector();
103
     return ByteVector();
103
+    
104
+  }
105
+
104
+  return s.data(String::Latin1ID3);
106
+  return s.data(String::Latin1ID3);
105
 }
107
 }
106
 
108
 
107
 ////////////////////////////////////////////////////////////////////////////////
109
 ////////////////////////////////////////////////////////////////////////////////
108
@@ -262,7 +262,7 @@ void ID3v1::Tag::parse(const ByteVector &data)
110
@@ -262,7 +265,7 @@ void ID3v1::Tag::parse(const ByteVector &data)
109
     d->track   = static_cast<unsigned char>(data[offset + 29]);
111
     d->track   = static_cast<unsigned char>(data[offset + 29]);
110
   }
112
   }
111
   else
113
   else
Lines 114-124 Link Here
114
 
116
 
115
   offset += 30;
117
   offset += 30;
116
 
118
 
117
diff --git taglib/mpeg/id3v2/frames/commentsframe.cpp taglib/mpeg/id3v2/frames/commentsframe.cpp
119
diff --git a/taglib/mpeg/id3v2/frames/commentsframe.cpp b/taglib/mpeg/id3v2/frames/commentsframe.cpp
118
index b561832..9cfaba2 100644
120
index 815e5e1..cf25328 100644
119
--- taglib/mpeg/id3v2/frames/commentsframe.cpp
121
--- taglib/mpeg/id3v2/frames/commentsframe.cpp
120
+++ taglib/mpeg/id3v2/frames/commentsframe.cpp
122
+++ taglib/mpeg/id3v2/frames/commentsframe.cpp
121
@@ -148,10 +148,10 @@ void CommentsFrame::parseFields(const ByteVector &data)
123
@@ -150,10 +150,10 @@ void CommentsFrame::parseFields(const ByteVector &data)
122
     return;
124
     return;
123
   }
125
   }
124
 
126
 
Lines 131-143 Link Here
131
 
133
 
132
   ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
134
   ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
133
 
135
 
134
@@ -171,11 +171,13 @@ ByteVector CommentsFrame::renderFields() const
136
@@ -174,10 +174,12 @@ ByteVector CommentsFrame::renderFields() const
135
   ByteVector v;
136
 
137
 
137
   String::Type encoding = d->textEncoding;
138
   String::Type encoding = d->textEncoding;
138
+  
139
 
139
+  encoding = String::ID3WType(encoding);
140
+  encoding = String::ID3WType(encoding);
140
 
141
+
141
   encoding = checkTextEncoding(d->description, encoding);
142
   encoding = checkTextEncoding(d->description, encoding);
142
   encoding = checkTextEncoding(d->text, encoding);
143
   encoding = checkTextEncoding(d->text, encoding);
143
 
144
 
Lines 146-153 Link Here
146
   v.append(d->language.size() == 3 ? d->language : "XXX");
147
   v.append(d->language.size() == 3 ? d->language : "XXX");
147
   v.append(d->description.data(encoding));
148
   v.append(d->description.data(encoding));
148
   v.append(textDelimiter(encoding));
149
   v.append(textDelimiter(encoding));
149
diff --git taglib/mpeg/id3v2/frames/textidentificationframe.cpp taglib/mpeg/id3v2/frames/textidentificationframe.cpp
150
diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
150
index d9d3b29..74f69da 100644
151
index 9b1eacd..464d951 100644
151
--- taglib/mpeg/id3v2/frames/textidentificationframe.cpp
152
--- taglib/mpeg/id3v2/frames/textidentificationframe.cpp
152
+++ taglib/mpeg/id3v2/frames/textidentificationframe.cpp
153
+++ taglib/mpeg/id3v2/frames/textidentificationframe.cpp
153
@@ -191,12 +191,12 @@ void TextIdentificationFrame::parseFields(const ByteVector &data)
154
@@ -191,12 +191,12 @@ void TextIdentificationFrame::parseFields(const ByteVector &data)
Lines 171-177 Link Here
171
 {
172
 {
172
-  String::Type encoding = checkTextEncoding(d->fieldList, d->textEncoding);
173
-  String::Type encoding = checkTextEncoding(d->fieldList, d->textEncoding);
173
+  String::Type encoding = d->textEncoding;
174
+  String::Type encoding = d->textEncoding;
174
+  
175
+
175
+  encoding = String::ID3WType(encoding);
176
+  encoding = String::ID3WType(encoding);
176
+  encoding = checkTextEncoding(d->fieldList, encoding);
177
+  encoding = checkTextEncoding(d->fieldList, encoding);
177
 
178
 
Lines 182-189 Link Here
182
 
183
 
183
   for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {
184
   for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {
184
 
185
 
185
diff --git taglib/mpeg/id3v2/id3v2frame.cpp taglib/mpeg/id3v2/id3v2frame.cpp
186
diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp
186
index 1f896fa..ef9d91d 100644
187
index af4136a..e792d63 100644
187
--- taglib/mpeg/id3v2/id3v2frame.cpp
188
--- taglib/mpeg/id3v2/id3v2frame.cpp
188
+++ taglib/mpeg/id3v2/id3v2frame.cpp
189
+++ taglib/mpeg/id3v2/id3v2frame.cpp
189
@@ -297,7 +297,7 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin
190
@@ -297,7 +297,7 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin
Lines 195-206 Link Here
195
     return encoding;
196
     return encoding;
196
 
197
 
197
   for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
198
   for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
198
diff --git taglib/toolkit/rccpatch.cpp taglib/toolkit/rccpatch.cpp
199
diff --git a/taglib/toolkit/rccpatch.cpp b/taglib/toolkit/rccpatch.cpp
199
new file mode 100644
200
new file mode 100644
200
index 0000000..af99323
201
index 0000000..2e40e01
201
--- /dev/null
202
--- /dev/null
202
+++ taglib/toolkit/rccpatch.cpp
203
+++ taglib/toolkit/rccpatch.cpp
203
@@ -0,0 +1,237 @@
204
@@ -0,0 +1,235 @@
204
+#include <stdlib.h>
205
+#include <stdlib.h>
205
+
206
+
206
+#include <string>
207
+#include <string>
Lines 275-281 Link Here
275
+#ifdef HAVE_LIBRCC
276
+#ifdef HAVE_LIBRCC
276
+    if (!rcc_initialized) {
277
+    if (!rcc_initialized) {
277
+	rccTaglibPatchInit();
278
+	rccTaglibPatchInit();
278
+	if (rcc_initialized) atexit(rccTaglibPatchFree);	
279
+	if (rcc_initialized) atexit(rccTaglibPatchFree);
279
+    }
280
+    }
280
+#endif /* HAVE_LIBRCC */
281
+#endif /* HAVE_LIBRCC */
281
+}
282
+}
Lines 306-312 Link Here
306
+    return v;
307
+    return v;
307
+#else
308
+#else
308
+    v.setData("", 0);
309
+    v.setData("", 0);
309
+    
310
+
310
+    return v;
311
+    return v;
311
+#endif /* HAVE_LIBRCC */
312
+#endif /* HAVE_LIBRCC */
312
+}
313
+}
Lines 336-342 Link Here
336
+    return v;
337
+    return v;
337
+#else
338
+#else
338
+    v.setData("", 0);
339
+    v.setData("", 0);
339
+    
340
+
340
+    return v;
341
+    return v;
341
+#endif /* HAVE_LIBRCC */
342
+#endif /* HAVE_LIBRCC */
342
+}
343
+}
Lines 363-369 Link Here
363
+    else
364
+    else
364
+#endif /* HAVE_LIBRCC */
365
+#endif /* HAVE_LIBRCC */
365
+    v.setData("", 0);
366
+    v.setData("", 0);
366
+    
367
+
367
+    return v;
368
+    return v;
368
+}
369
+}
369
+
370
+
Lines 401-407 Link Here
401
+    if (!rccLocaleGetCharset(charset, NULL, 31)) {
402
+    if (!rccLocaleGetCharset(charset, NULL, 31)) {
402
+	if (!strncmp(charset, "UTF", 3)) {
403
+	if (!strncmp(charset, "UTF", 3)) {
403
+	    len = strlen(charset);
404
+	    len = strlen(charset);
404
+	    
405
+	    if (charset[len-1]=='8') return TagLib::String::UTF8;
405
+	    if (charset[len-1]=='8') return TagLib::String::UTF8;
406
+	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
406
+	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
407
+	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
407
+	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
Lines 419-430 Link Here
419
+    const char *charset;
419
+    const char *charset;
420
+
420
+
421
+    rccTaglibPatchTryInit();
421
+    rccTaglibPatchTryInit();
422
+    
422
+
423
+    charset = rccGetCurrentCharsetName(ctx, ID3V2_CLASS);
423
+    charset = rccGetCurrentCharsetName(ctx, ID3V2_CLASS);
424
+    if (charset) {
424
+    if (charset) {
425
+	if (!strncmp(charset, "UTF", 3)) {
425
+	if (!strncmp(charset, "UTF", 3)) {
426
+	    len = strlen(charset);
426
+	    len = strlen(charset);
427
+	    
428
+	    if (charset[len-1]=='8') return TagLib::String::UTF8;
427
+	    if (charset[len-1]=='8') return TagLib::String::UTF8;
429
+	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
428
+	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
430
+	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
429
+	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
Lines 438-444 Link Here
438
+#endif /* HAVE_LIBRCC */
437
+#endif /* HAVE_LIBRCC */
439
+    return TagLib::String::Latin1;
438
+    return TagLib::String::Latin1;
440
+}
439
+}
441
diff --git taglib/toolkit/rccpatch.h taglib/toolkit/rccpatch.h
440
diff --git a/taglib/toolkit/rccpatch.h b/taglib/toolkit/rccpatch.h
442
new file mode 100644
441
new file mode 100644
443
index 0000000..31f4410
442
index 0000000..31f4410
444
--- /dev/null
443
--- /dev/null
Lines 464-474 Link Here
464
+TagLib::String::Type rccTaglibPatchGetID3Type();
463
+TagLib::String::Type rccTaglibPatchGetID3Type();
465
+
464
+
466
+#endif /* _RCC_PATCH_H */
465
+#endif /* _RCC_PATCH_H */
467
diff --git taglib/toolkit/tstring.cpp taglib/toolkit/tstring.cpp
466
diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp
468
index 8328790..278256f 100644
467
index c60a3e2..7249c83 100644
469
--- taglib/toolkit/tstring.cpp
468
--- taglib/toolkit/tstring.cpp
470
+++ taglib/toolkit/tstring.cpp
469
+++ taglib/toolkit/tstring.cpp
471
@@ -42,6 +42,7 @@
470
@@ -33,6 +33,7 @@
472
 #include <trefcounter.h>
471
 #include <trefcounter.h>
473
 #include <tutils.h>
472
 #include <tutils.h>
474
 
473
 
Lines 476-535 Link Here
476
 #include "tstring.h"
475
 #include "tstring.h"
477
 
476
 
478
 namespace
477
 namespace
479
@@ -120,15 +121,37 @@ namespace
478
@@ -48,16 +49,6 @@ namespace
480
     else
481
       return String::UTF16BE;
479
       return String::UTF16BE;
482
   }
480
   }
483
+  
484
+  void copyFromUTF8(std::wstring &data, const char *s, size_t length);
485
 
481
 
486
   // Converts a Latin-1 string into UTF-16(without BOM/CPU byte order)
482
-  // Converts a Latin-1 string into UTF-16(without BOM/CPU byte order)
483
-  // and copies it to the internal buffer.
484
-  void copyFromLatin1(std::wstring &data, const char *s, size_t length)
485
-  {
486
-    data.resize(length);
487
-
488
-    for(size_t i = 0; i < length; ++i)
489
-      data[i] = static_cast<unsigned char>(s[i]);
490
-  }
491
-
492
   // Converts a UTF-8 string into UTF-16(without BOM/CPU byte order)
487
   // and copies it to the internal buffer.
493
   // and copies it to the internal buffer.
488
-  void copyFromLatin1(std::wstring &data, const char *s, size_t length)
494
   void copyFromUTF8(std::wstring &data, const char *s, size_t length)
489
+  void copyFromLatin1(std::wstring &data, const char *s, size_t length, bool prepare = false, String::Type t = String::Latin1)
495
@@ -73,6 +64,36 @@ namespace
490
   {
496
       debug("String::copyFromUTF8() - UTF8-CPP error: " + message);
491
     data.resize(length);
497
       data.clear();
492
 
498
     }
493
     for(size_t i = 0; i < length; ++i)
499
+
494
       data[i] = static_cast<unsigned char>(s[i]);
500
+  }
495
+      
501
+
496
+         
502
+  // Converts a Latin-1 string into UTF-16(without BOM/CPU byte order)
497
+    // librcc conversation
503
+  // and copies it to the internal buffer.
504
+  void copyFromLatin1(std::wstring &data, const char *s, size_t length, bool prepare, String::Type t)
505
+  {
506
+     // librcc conversation
498
+    if (prepare) {
507
+    if (prepare) {
499
+     
508
+      ByteVector v;
500
+     ByteVector v;
509
+      std::string std_s(s);
501
+     std::string str = std::string(s, length);
502
+    
503
+     if (t == String::Latin1ID3) v = rccTaglibPatchRecodeInputID3(str, false);
504
+     else if (t == String::Latin1ID3V2) v = rccTaglibPatchRecodeInputID3(str, true);
505
+     else /* Latin1 converted from Locale */ v = rccTaglibPatchRecodeInput(str);
506
+
510
+
507
+     if (v.size()) {
511
+      if (t == String::Latin1ID3) v = rccTaglibPatchRecodeInputID3(std_s, false);
508
+       copyFromUTF8(data, v.data(), v.size());
512
+      else if (t == String::Latin1ID3V2) v = rccTaglibPatchRecodeInputID3(std_s, true);
509
+     } else {
513
+      else /* Latin1 converted from Locale */ v = rccTaglibPatchRecodeInput(std_s);
510
+     // We don't know if we got UTF-8 encoded string or either rcc is disable or something is failed,
514
+
511
+     // since standard applications are really expecting here Latin1, it is safe to just check if we have violations of UTF8
515
+      if (v.size()) {
512
+     //if (Unicode::isLegalUTF8(s)) t = UTF8;
516
+        copyFromUTF8(data, v.data(), v.size());
513
+     }
517
+        return;
514
+    }      
518
+      } else {
519
+	// We don't know if we got UTF-8 encoded string or either rcc is disable or something is failed,
520
+	// since standard applications are really expecting here Latin1, it is safe to just check if we have violations of UTF8
521
+	//if (Unicode::isLegalUTF8(s)) t = UTF8;
522
+      }
523
+    }
524
+
525
+    data.resize(length);
526
+
527
+    for(size_t i = 0; i < length; ++i)
528
+      data[i] = static_cast<unsigned char>(s[i]);
515
   }
529
   }
516
 
530
 
517
   // Converts a UTF-8 string into UTF-16(without BOM/CPU byte order)
531
   // Helper functions to read a UTF-16 character from an array.
518
@@ -264,8 +287,11 @@ String::String(const String &s) :
532
@@ -175,8 +196,11 @@ String::String(const String &s) :
519
 String::String(const std::string &s, Type t) :
533
 String::String(const std::string &s, Type t) :
520
   d(new StringPrivate())
534
   d(new StringPrivate())
521
 {
535
 {
522
-  if(t == Latin1)
523
-    copyFromLatin1(d->data, s.c_str(), s.length());
524
+  if(t == Locale)
536
+  if(t == Locale)
525
+   t = rccTaglibPatchGetLocaleType();
537
+    t = rccTaglibPatchGetLocaleType();
526
+
538
+
527
+  if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
539
   if(t == Latin1)
540
-    copyFromLatin1(d->data, s.c_str(), s.length());
528
+    copyFromLatin1(d->data, s.c_str(), s.length(), true, t);
541
+    copyFromLatin1(d->data, s.c_str(), s.length(), true, t);
529
   else if(t == String::UTF8)
542
   else if(t == String::UTF8)
530
     copyFromUTF8(d->data, s.c_str(), s.length());
543
     copyFromUTF8(d->data, s.c_str(), s.length());
531
   else {
544
   else {
532
@@ -312,8 +338,11 @@ String::String(const wchar_t *s, Type t) :
545
@@ -223,8 +247,11 @@ String::String(const wchar_t *s, Type t) :
533
 String::String(const char *s, Type t) :
546
 String::String(const char *s, Type t) :
534
   d(new StringPrivate())
547
   d(new StringPrivate())
535
 {
548
 {
Lines 543-571 Link Here
543
   else if(t == String::UTF8)
556
   else if(t == String::UTF8)
544
     copyFromUTF8(d->data, s, ::strlen(s));
557
     copyFromUTF8(d->data, s, ::strlen(s));
545
   else {
558
   else {
546
@@ -344,9 +373,13 @@ String::String(const ByteVector &v, Type t) :
559
@@ -245,8 +272,11 @@ String::String(wchar_t c, Type t) :
560
 String::String(char c, Type t) :
561
   d(new StringPrivate())
547
 {
562
 {
563
-  if(t == Latin1)
564
-    copyFromLatin1(d->data, &c, 1);
565
+  if(t == Locale)
566
+    t = rccTaglibPatchGetLocaleType();
567
+
568
+  if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
569
+    copyFromLatin1(d->data, &c, 1, true, t);
570
   else if(t == String::UTF8)
571
     copyFromUTF8(d->data, &c, 1);
572
   else {
573
@@ -260,8 +290,11 @@ String::String(const ByteVector &v, Type t) :
548
   if(v.isEmpty())
574
   if(v.isEmpty())
549
     return;
575
     return;
550
+    
551
+  if(t == Locale)
552
+   t = rccTaglibPatchGetLocaleType();
553
+
554
+   if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
555
+     copyFromLatin1(d->data, v.data(), v.size(), true, t);
556
 
576
 
557
-  if(t == Latin1)
577
-  if(t == Latin1)
558
-    copyFromLatin1(d->data, v.data(), v.size());
578
-    copyFromLatin1(d->data, v.data(), v.size());
579
+  if(t == Locale)
580
+    t = rccTaglibPatchGetLocaleType();
581
+
582
+  if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
583
+    copyFromLatin1(d->data, v.data(), v.size(), true, t);
559
   else if(t == UTF8)
584
   else if(t == UTF8)
560
     copyFromUTF8(d->data, v.data(), v.size());
585
     copyFromUTF8(d->data, v.data(), v.size());
561
   else
586
   else
562
@@ -499,8 +532,38 @@ bool String::isNull() const
587
@@ -416,8 +449,38 @@ bool String::isNull() const
563
 
588
 
564
 ByteVector String::data(Type t) const
589
 ByteVector String::data(Type t) const
565
 {
590
 {
566
-  switch(t)
591
-  switch(t)
567
-  {
592
-  {
568
+   ByteVector v;
593
+  ByteVector v;
569
+
594
+
570
+  if (t == Locale) {
595
+  if (t == Locale) {
571
+        // The source is either Unicode or real Latin1 (if rcc is bypassed)
596
+        // The source is either Unicode or real Latin1 (if rcc is bypassed)
Lines 585-593 Link Here
585
+      std::string s = to8Bit(true);
610
+      std::string s = to8Bit(true);
586
+      if (t == Latin1ID3) v = rccTaglibPatchRecodeOutputID3(s, false);
611
+      if (t == Latin1ID3) v = rccTaglibPatchRecodeOutputID3(s, false);
587
+      else if (t == Latin1ID3V2) v = rccTaglibPatchRecodeOutputID3(s, true);
612
+      else if (t == Latin1ID3V2) v = rccTaglibPatchRecodeOutputID3(s, true);
588
+      if (v.size()) 
613
+      if (v.size())
589
+        return v;
614
+        return v;
590
+      
615
+
591
+          // we don't know if we got NULL because rcc is disabled (error) or UTF8 output is required
616
+          // we don't know if we got NULL because rcc is disabled (error) or UTF8 output is required
592
+      if ((t == Latin1ID3V2)&&(rccTaglibPatchGetID3Type() == UTF8)) {
617
+      if ((t == Latin1ID3V2)&&(rccTaglibPatchGetID3Type() == UTF8)) {
593
+          v.setData(s.c_str(), s.length());
618
+          v.setData(s.c_str(), s.length());
Lines 600-606 Link Here
600
   case Latin1:
625
   case Latin1:
601
     {
626
     {
602
       ByteVector v(size(), 0);
627
       ByteVector v(size(), 0);
603
@@ -822,7 +885,35 @@ const TagLib::String operator+(const TagLib::String &s1, const char *s2)
628
@@ -741,7 +804,33 @@ const TagLib::String operator+(const TagLib::String &s1, const char *s2)
604
 
629
 
605
 std::ostream &operator<<(std::ostream &s, const TagLib::String &str)
630
 std::ostream &operator<<(std::ostream &s, const TagLib::String &str)
606
 {
631
 {
Lines 635-673 Link Here
635
+    return Latin1;
660
+    return Latin1;
636
+  return type;
661
+  return type;
637
+}
662
+}
638
+
663
diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h
639
+
664
index 7028aab..715d04d 100644
640
diff --git taglib/toolkit/tstring.h taglib/toolkit/tstring.h
641
index b1be04b..b21f297 100644
642
--- taglib/toolkit/tstring.h
665
--- taglib/toolkit/tstring.h
643
+++ taglib/toolkit/tstring.h
666
+++ taglib/toolkit/tstring.h
644
@@ -96,6 +96,18 @@ namespace TagLib {
667
@@ -95,6 +95,18 @@ namespace TagLib {
668
      * ID3v1 is assumed to be Latin1 and Ogg Vorbis comments use UTF8.
645
      */
669
      */
646
     enum Type {
670
     enum Type {
647
       /*!
671
+      /*!
648
+        * Determine using current locale settings
672
+       * Determine using current locale settings
649
+        */
673
+       */
650
+      Locale = -1,
674
+      Locale = -1,
651
+       /*!
675
+      /*!
652
+        * Latin1 for ID3 tags.
676
+       * Latin1 for ID3 tags.
653
+        */
677
+       */
654
+      Latin1ID3 = 65,
678
+      Latin1ID3 = 65,
655
+       /*!
679
+      /*!
656
+        * Latin1 for ID3v2 tags.
680
+       * Latin1 for ID3v2 tags.
657
+        */
681
+       */
658
+      Latin1ID3V2 = 66,
682
+      Latin1ID3V2 = 66,
659
+      /*!
683
       /*!
660
        * IS08859-1, or <i>Latin1</i> encoding.  8 bit characters.
684
        * IS08859-1, or <i>Latin1</i> encoding.  8 bit characters.
661
        */
685
        */
662
       Latin1 = 0,
686
@@ -118,6 +130,10 @@ namespace TagLib {
663
@@ -117,6 +129,10 @@ namespace TagLib {
664
        */
665
       UTF16LE = 4
687
       UTF16LE = 4
666
     };
688
     };
667
+    
689
 
668
+    static Type ID3Type(int i);
690
+    static Type ID3Type(int i);
669
+    static Type ID3WType(Type type);
691
+    static Type ID3WType(Type type);
670
+    static Type ID3RealType(Type type);
692
+    static Type ID3RealType(Type type);
671
 
693
+
672
     /*!
694
     /*!
673
      * Constructs an empty String.
695
      * Constructs an empty String.
696
      */
(-)audio/taglib/pkg-plist (+1 lines)
Lines 30-35 Link Here
30
include/taglib/id3v2framefactory.h
30
include/taglib/id3v2framefactory.h
31
include/taglib/id3v2header.h
31
include/taglib/id3v2header.h
32
include/taglib/id3v2synchdata.h
32
include/taglib/id3v2synchdata.h
33
include/taglib/id3v2.h
33
include/taglib/id3v2tag.h
34
include/taglib/id3v2tag.h
34
include/taglib/infotag.h
35
include/taglib/infotag.h
35
include/taglib/itfile.h
36
include/taglib/itfile.h

Return to bug 246025