View | Details | Raw Unified | Return to bug 276677 | Differences between
and this patch

Collapse All | Expand All

(-)b/audio/taglib/Makefile (-22 / +8 lines)
Lines 1-5 Link Here
1
PORTNAME=	taglib
1
PORTNAME=	taglib
2
DISTVERSION=	1.13.1
2
DISTVERSION=	2.0.1
3
CATEGORIES=	audio
3
CATEGORIES=	audio
4
MASTER_SITES=	https://github.com/${PORTNAME}/${PORTNAME}/releases/download/v${DISTVERSION}/ \
4
MASTER_SITES=	https://github.com/${PORTNAME}/${PORTNAME}/releases/download/v${DISTVERSION}/ \
5
		https://taglib.org/releases/
5
		https://taglib.org/releases/
Lines 8-47 MAINTAINER= jhale@FreeBSD.org Link Here
8
COMMENT=	Library for manipulating ID3 tags and Ogg comments
8
COMMENT=	Library for manipulating ID3 tags and Ogg comments
9
WWW=		https://taglib.org/
9
WWW=		https://taglib.org/
10
10
11
LICENSE=	LGPL21 MPL11
11
LICENSE=		LGPL21 MPL11
12
LICENSE_COMB=	dual
12
LICENSE_COMB=		dual
13
LICENSE_FILE_LGPL21=	${WRKSRC}/COPYING.LGPL
13
LICENSE_FILE_LGPL21=	${WRKSRC}/COPYING.LGPL
14
LICENSE_FILE_MPL11=	${WRKSRC}/COPYING.MPL
14
LICENSE_FILE_MPL11=	${WRKSRC}/COPYING.MPL
15
15
16
USES=		cmake compiler:c++11-lang cpe pathfix
16
BUILD_DEPENDS=	utf8cpp>0:devel/utf8cpp
17
18
USES=		cmake compiler:c++17-lang cpe pathfix
17
USE_LDCONFIG=	yes
19
USE_LDCONFIG=	yes
18
20
19
CMAKE_ARGS=	-DCMAKE_CXX_VISIBILITY_PRESET=hidden
21
CMAKE_ARGS=	-DCMAKE_CXX_VISIBILITY_PRESET=hidden
20
CMAKE_ON=	VISIBILITY_HIDDEN \
22
CMAKE_ON=	VISIBILITY_HIDDEN
21
		WITH_ASF \
22
		WITH_MP4
23
23
24
OPTIONS_DEFINE=	RCC STATIC TEST
24
OPTIONS_DEFINE=	STATIC TEST
25
OPTIONS_SUB=	yes
25
OPTIONS_SUB=	yes
26
26
27
# The official patches for this can be obtained from:
28
#   http://darksoft.org/files/rusxmms/patches/
29
#
30
RCC_DESC=		Build with RusXMMS librcc patches (experimental)
31
RCC_LIB_DEPENDS=	librcc.so:devel/librcc
32
RCC_USES=		localbase:ldflags
33
RCC_EXTRA_PATCHES=	${FILESDIR}/extrapatch-rcc
34
35
STATIC_CMAKE_BOOL_OFF=	BUILD_SHARED_LIBS
27
STATIC_CMAKE_BOOL_OFF=	BUILD_SHARED_LIBS
36
28
37
TEST_BUILD_DEPENDS=	cppunit-config:devel/cppunit
29
TEST_BUILD_DEPENDS=	cppunit-config:devel/cppunit
38
TEST_CMAKE_BOOL=	BUILD_TESTING
30
TEST_CMAKE_BOOL=	BUILD_TESTING
39
TEST_TEST_TARGET=	check
31
TEST_TEST_TARGET=	check
40
32
41
post-patch-RCC-on:
42
	@${REINPLACE_CMD} -e 's|-ltag|-ltag -lrcc|g' \
43
		${WRKSRC}/taglib.pc.cmake ${WRKSRC}/taglib-config.cmake
44
	@${REINPLACE_CMD} -e 's|-ltag_c|-ltag_c -lrcc|g' \
45
		${WRKSRC}/bindings/c/taglib_c.pc.cmake
46
47
.include <bsd.port.mk>
33
.include <bsd.port.mk>
(-)b/audio/taglib/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1688325610
1
TIMESTAMP = 1717381906
2
SHA256 (taglib-1.13.1.tar.gz) = c8da2b10f1bfec2cd7dbfcd33f4a2338db0765d851a50583d410bacf055cfd0b
2
SHA256 (taglib-2.0.1.tar.gz) = 08c0a27b96aa5c4e23060fe0b6f93102ee9091a9385257b9d0ddcf467de0d925
3
SIZE (taglib-1.13.1.tar.gz) = 1372618
3
SIZE (taglib-2.0.1.tar.gz) = 1432624
(-)a/audio/taglib/files/extrapatch-rcc (-668 lines)
Removed Link Here
1
diff --git a/CMakeLists.txt b/CMakeLists.txt
2
index 832af866..d02ccaf1 100644
3
--- CMakeLists.txt
4
+++ CMakeLists.txt
5
@@ -139,6 +139,8 @@ if(NOT BUILD_FRAMEWORK)
6
   install(FILES "${CMAKE_CURRENT_BINARY_DIR}/taglib.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
7
 endif()
8
 
9
+SET(HAVE_LIBRCC 1)
10
+
11
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
12
 configure_file(config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/config.h")
13
 
14
diff --git a/config.h.cmake b/config.h.cmake
15
index 8d8c36ab..ccae081b 100644
16
--- config.h.cmake
17
+++ config.h.cmake
18
@@ -29,6 +29,9 @@
19
 /* Indicates whether debug messages are shown even in release mode */
20
 #cmakedefine   TRACE_IN_RELEASE 1
21
 
22
+/* Defined if you have LibRCC from RusXMMS project */
23
+#cmakedefine   HAVE_LIBRCC 1
24
+
25
 #cmakedefine TESTS_DIR "@TESTS_DIR@"
26
 
27
 #endif
28
diff --git a/examples/tagreader_c.c b/examples/tagreader_c.c
29
index 04369926..e0f17d82 100644
30
--- examples/tagreader_c.c
31
+++ examples/tagreader_c.c
32
@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
33
   TagLib_Tag *tag;
34
   const TagLib_AudioProperties *properties;
35
 
36
-  taglib_set_strings_unicode(FALSE);
37
+  //taglib_set_strings_unicode(FALSE);
38
 
39
   for(i = 1; i < argc; i++) {
40
     printf("******************** \"%s\" ********************\n", argv[i]);
41
diff --git a/examples/tagwriter.cpp b/examples/tagwriter.cpp
42
index ed8b0d7a..6a7a2632 100644
43
--- examples/tagwriter.cpp
44
+++ examples/tagwriter.cpp
45
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
46
     if(isArgument(argv[i]) && i + 1 < argc && !isArgument(argv[i + 1])) {
47
 
48
       char field = argv[i][1];
49
-      TagLib::String value = argv[i + 1];
50
+      TagLib::String value(argv[i + 1], TagLib::String::Locale);
51
 
52
       TagLib::List<TagLib::FileRef>::ConstIterator it;
53
       for(it = fileList.begin(); it != fileList.end(); ++it) {
54
diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt
55
index ea1ab838..2f7bad07 100644
56
--- taglib/CMakeLists.txt
57
+++ taglib/CMakeLists.txt
58
@@ -39,6 +39,7 @@ set(tag_HDRS
59
   audioproperties.h
60
   taglib_export.h
61
   ${CMAKE_CURRENT_BINARY_DIR}/../taglib_config.h
62
+  toolkit/rccpatch.h
63
   toolkit/taglib.h
64
   toolkit/tstring.h
65
   toolkit/tlist.h
66
@@ -295,6 +296,7 @@ set(xm_SRCS
67
 )
68
 
69
 set(toolkit_SRCS
70
+  toolkit/rccpatch.cpp
71
   toolkit/tstring.cpp
72
   toolkit/tstringlist.cpp
73
   toolkit/tbytevector.cpp
74
@@ -338,7 +340,9 @@ add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
75
 set_property(TARGET tag PROPERTY CXX_STANDARD 98)
76
 
77
 if(HAVE_ZLIB AND NOT HAVE_ZLIB_SOURCE)
78
-  target_link_libraries(tag ${ZLIB_LIBRARIES})
79
+  target_link_libraries(tag rcc ${ZLIB_LIBRARIES})
80
+else()
81
+  target_link_libraries(tag rcc)
82
 endif()
83
 
84
 set_target_properties(tag PROPERTIES
85
diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp
86
index 667adfa6..8b2ceef5 100644
87
--- taglib/mpeg/id3v1/id3v1tag.cpp
88
+++ taglib/mpeg/id3v1/id3v1tag.cpp
89
@@ -69,14 +69,14 @@ StringHandler::StringHandler()
90
 
91
 String ID3v1::StringHandler::parse(const ByteVector &data) const
92
 {
93
-  return String(data, String::Latin1).stripWhiteSpace();
94
+  return String(data, String::Latin1ID3).stripWhiteSpace();
95
 }
96
 
97
 ByteVector ID3v1::StringHandler::render(const String &s) const
98
 {
99
-  if(s.isLatin1())
100
-    return s.data(String::Latin1);
101
-  return ByteVector();
102
+  if(!s.isLatin1() && String::ID3WType(String::Latin1) == String::Latin1)
103
+    return ByteVector();
104
+  return s.data(String::Latin1ID3);
105
 }
106
 
107
 ////////////////////////////////////////////////////////////////////////////////
108
@@ -259,7 +259,7 @@ void ID3v1::Tag::parse(const ByteVector &data)
109
     d->track   = static_cast<unsigned char>(data[offset + 29]);
110
   }
111
   else
112
-    d->comment = data.mid(offset, 30);
113
+    d->comment = stringHandler->parse(data.mid(offset, 30));
114
 
115
   offset += 30;
116
 
117
diff --git a/taglib/mpeg/id3v2/frames/commentsframe.cpp b/taglib/mpeg/id3v2/frames/commentsframe.cpp
118
index add0bf2f..b641c49d 100644
119
--- taglib/mpeg/id3v2/frames/commentsframe.cpp
120
+++ taglib/mpeg/id3v2/frames/commentsframe.cpp
121
@@ -150,10 +150,10 @@ void CommentsFrame::parseFields(const ByteVector &data)
122
     return;
123
   }
124
 
125
-  d->textEncoding = static_cast<String::Type>(data[0]);
126
+  d->textEncoding = String::ID3Type(data[0]);
127
   d->language = data.mid(1, 3);
128
 
129
-  int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
130
+  int byteAlign = (d->textEncoding == String::Latin1 || d->textEncoding == String::Latin1ID3 || d->textEncoding == String::Latin1ID3V2 || d->textEncoding == String::UTF8) ? 1 : 2;
131
 
132
   ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
133
 
134
@@ -174,10 +174,12 @@ ByteVector CommentsFrame::renderFields() const
135
 
136
   String::Type encoding = d->textEncoding;
137
 
138
+  encoding = String::ID3WType(encoding);
139
+
140
   encoding = checkTextEncoding(d->description, encoding);
141
   encoding = checkTextEncoding(d->text, encoding);
142
 
143
-  v.append(static_cast<char>(encoding));
144
+  v.append(static_cast<char>(String::ID3RealType(encoding)));
145
   v.append(d->language.size() == 3 ? d->language : "XXX");
146
   v.append(d->description.data(encoding));
147
   v.append(textDelimiter(encoding));
148
diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
149
index cda40d95..6ac15400 100644
150
--- taglib/mpeg/id3v2/frames/textidentificationframe.cpp
151
+++ taglib/mpeg/id3v2/frames/textidentificationframe.cpp
152
@@ -194,12 +194,12 @@ void TextIdentificationFrame::parseFields(const ByteVector &data)
153
 
154
   // read the string data type (the first byte of the field data)
155
 
156
-  d->textEncoding = static_cast<String::Type>(data[0]);
157
+  d->textEncoding = String::ID3Type(data[0]);
158
 
159
   // split the byte array into chunks based on the string type (two byte delimiter
160
   // for unicode encodings)
161
 
162
-  int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
163
+  int byteAlign = (d->textEncoding == String::Latin1 || d->textEncoding == String::Latin1ID3 || d->textEncoding == String::Latin1ID3V2 || d->textEncoding == String::UTF8) ? 1 : 2;
164
 
165
   // build a small counter to strip nulls off the end of the field
166
 
167
@@ -250,11 +250,14 @@ void TextIdentificationFrame::parseFields(const ByteVector &data)
168
 
169
 ByteVector TextIdentificationFrame::renderFields() const
170
 {
171
-  String::Type encoding = checkTextEncoding(d->fieldList, d->textEncoding);
172
+  String::Type encoding = d->textEncoding;
173
+
174
+  encoding = String::ID3WType(encoding);
175
+  encoding = checkTextEncoding(d->fieldList, encoding);
176
 
177
   ByteVector v;
178
 
179
-  v.append(static_cast<char>(encoding));
180
+  v.append(static_cast<char>(String::ID3RealType(encoding)));
181
 
182
   for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {
183
 
184
diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp
185
index c3a45a2a..fac929b9 100644
186
--- taglib/mpeg/id3v2/id3v2frame.cpp
187
+++ taglib/mpeg/id3v2/id3v2frame.cpp
188
@@ -297,7 +297,7 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin
189
   if((encoding == String::UTF8 || encoding == String::UTF16BE) && version != 4)
190
     return String::UTF16;
191
 
192
-  if(encoding != String::Latin1)
193
+  if((encoding != String::Latin1)&&(encoding != String::Latin1ID3V2))
194
     return encoding;
195
 
196
   for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
197
diff --git a/taglib/toolkit/rccpatch.cpp b/taglib/toolkit/rccpatch.cpp
198
new file mode 100644
199
index 00000000..972874e3
200
--- /dev/null
201
+++ taglib/toolkit/rccpatch.cpp
202
@@ -0,0 +1,237 @@
203
+#include <stdlib.h>
204
+
205
+#include <string>
206
+#include "tstring.h"
207
+#include "tbytevector.h"
208
+
209
+//#define RCC_DEBUG
210
+
211
+
212
+#ifndef HAVE_LIBRCC
213
+# include <config.h>
214
+#endif
215
+
216
+#ifdef HAVE_LIBRCC
217
+# ifdef RCC_DEBUG
218
+#  include <stdio.h>
219
+# endif /* RCC_DEBUG */
220
+# include <librcc.h>
221
+# include <string.h>
222
+#endif /* HAVE_LIBRCC */
223
+
224
+
225
+#ifdef HAVE_LIBRCC
226
+# define ID3_CLASS 0
227
+# define ID3V2_CLASS 1
228
+# define UTF_CLASS 2
229
+# define OUT_CLASS 3
230
+static rcc_class classes[] = {
231
+    { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
232
+    { "id3v2", RCC_CLASS_STANDARD, "id3", NULL, "ID3 v.2 Encoding", 0 },
233
+    { "utf", RCC_CLASS_KNOWN, "UTF-8", NULL, "Unicode Encoding", 0},
234
+    { "out", RCC_CLASS_TRANSLATE_LOCALE, "LC_CTYPE", NULL, "Output Encoding", 0 },
235
+    { NULL, RCC_CLASS_STANDARD, NULL, NULL, NULL, 0 }
236
+};
237
+
238
+static int rcc_initialized = 0;
239
+
240
+static rcc_context ctx = NULL;
241
+#endif /* HAVE_LIBRCC */
242
+
243
+
244
+void rccTaglibPatchFree() {
245
+#ifdef HAVE_LIBRCC
246
+    if (rcc_initialized) {
247
+       rccFree();
248
+       rcc_initialized = 0;
249
+    }
250
+#endif /* HAVE_LIBRCC */
251
+}
252
+
253
+void rccTaglibPatchInit() {
254
+#ifdef HAVE_LIBRCC
255
+    if (rcc_initialized) return;
256
+    rccInit();
257
+    rccInitDefaultContext(NULL, 0, 0, classes, 0);
258
+    rccLoad(NULL, "xmms");
259
+    rccInitDb4(NULL, NULL, 0);
260
+    rcc_initialized = 1;
261
+#endif /* HAVE_LIBRCC */
262
+}
263
+
264
+void rccTaglibPatchSetContext(void *newctx) {
265
+#ifdef HAVE_LIBRCC
266
+    if (newctx) {
267
+	ctx = (rcc_context)newctx;
268
+	rcc_initialized = 1;
269
+    }
270
+#endif /* HAVE_LIBRCC */
271
+}
272
+
273
+static void rccTaglibPatchTryInit() {
274
+#ifdef HAVE_LIBRCC
275
+    if (!rcc_initialized) {
276
+	rccTaglibPatchInit();
277
+	if (rcc_initialized) atexit(rccTaglibPatchFree);
278
+    }
279
+#endif /* HAVE_LIBRCC */
280
+}
281
+
282
+
283
+TagLib::ByteVector rccTaglibPatchRecodeOutput(const std::string &s) {
284
+    TagLib::ByteVector v;
285
+#ifdef HAVE_LIBRCC
286
+    size_t rlen;
287
+    char *res;
288
+
289
+    rccTaglibPatchTryInit();
290
+
291
+    res = rccSizedRecode(ctx, UTF_CLASS, OUT_CLASS, s.c_str(), s.length(), &rlen);
292
+#ifdef RCC_DEBUG
293
+    for (const unsigned char *c = (const unsigned char*)s.c_str(); *c; c++) {
294
+	if (*c > 127) {
295
+	    printf(" Output: %s - %s\n", s.c_str(), res?res:"null");
296
+	    break;
297
+	}
298
+    }
299
+#endif /* RCC_DEBUG */
300
+
301
+    if (res) v.setData(res, rlen);
302
+    else v.setData("", 0);
303
+    //v.setData(s.c_str(), s.length());
304
+
305
+    return v;
306
+#else
307
+    v.setData("", 0);
308
+
309
+    return v;
310
+#endif /* HAVE_LIBRCC */
311
+}
312
+
313
+TagLib::ByteVector rccTaglibPatchRecodeOutputID3(const std::string &s, bool v2 = false) {
314
+    TagLib::ByteVector v;
315
+#ifdef HAVE_LIBRCC
316
+    size_t rlen;
317
+    char *res;
318
+
319
+    rccTaglibPatchTryInit();
320
+
321
+    res = rccSizedRecode(ctx, UTF_CLASS, v2?ID3V2_CLASS:ID3_CLASS, s.c_str(), s.length(), &rlen);
322
+#ifdef RCC_DEBUG
323
+    for (const unsigned char *c = (const unsigned char*)s.c_str(); *c; c++) {
324
+	if (*c > 127) {
325
+	    printf(" OutputID3(%i): %s - %s\n", v2, s.c_str(), res?res:"null");
326
+	    break;
327
+	}
328
+    }
329
+#endif /* RCC_DEBUG */
330
+
331
+    if (res) v.setData(res, rlen);
332
+    else v.setData("", 0);
333
+    //v.setData(s.c_str(), s.length());
334
+
335
+    return v;
336
+#else
337
+    v.setData("", 0);
338
+
339
+    return v;
340
+#endif /* HAVE_LIBRCC */
341
+}
342
+
343
+TagLib::ByteVector rccTaglibPatchRecodeInput(const std::string &s) {
344
+    TagLib::ByteVector v;
345
+#ifdef HAVE_LIBRCC
346
+    size_t rlen;
347
+    char *res;
348
+
349
+    rccTaglibPatchTryInit();
350
+
351
+    res = rccSizedRecode(ctx, OUT_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
352
+#ifdef RCC_DEBUG
353
+    for (const unsigned char *c = (const unsigned char*)s.c_str(); *c; c++) {
354
+	if (*c > 127) {
355
+	    printf(" Input: %s - %s\n", s.c_str(), res?res:"null");
356
+	    break;
357
+	}
358
+    }
359
+#endif /* RCC_DEBUG */
360
+
361
+    if (res) v.setData(res, rlen);
362
+    else
363
+#endif /* HAVE_LIBRCC */
364
+    v.setData("", 0);
365
+
366
+    return v;
367
+}
368
+
369
+TagLib::ByteVector rccTaglibPatchRecodeInputID3(const std::string &s, bool v2 = false) {
370
+    TagLib::ByteVector v;
371
+#ifdef HAVE_LIBRCC
372
+    size_t rlen;
373
+    char *res;
374
+
375
+    rccTaglibPatchTryInit();
376
+
377
+    res = rccSizedRecode(ctx, v2?ID3V2_CLASS:ID3_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
378
+#ifdef RCC_DEBUG
379
+    for (const unsigned char *c = (const unsigned char*)s.c_str(); *c; c++) {
380
+	if (*c > 127) {
381
+	    printf(" InputID3(%i): %s - %s\n", v2, s.c_str(), res?res:"null");
382
+	    break;
383
+	}
384
+    }
385
+#endif /* RCC_DEBUG */
386
+    if (res) v.setData(res, rlen + 1);
387
+    else
388
+#endif /* HAVE_LIBRCC */
389
+    v.setData("", 0);
390
+
391
+    return v;
392
+}
393
+
394
+TagLib::String::Type rccTaglibPatchGetLocaleType() {
395
+#ifdef HAVE_LIBRCC
396
+    size_t len;
397
+    char charset[32];
398
+
399
+    rccTaglibPatchTryInit();
400
+    if (!rccLocaleGetCharset(charset, NULL, 31)) {
401
+	if (!strncmp(charset, "UTF", 3)) {
402
+	    len = strlen(charset);
403
+
404
+	    if (charset[len-1]=='8') return TagLib::String::UTF8;
405
+	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
406
+	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
407
+	    if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
408
+	}
409
+	return TagLib::String::Latin1;
410
+    }
411
+#endif /* HAVE_LIBRCC */
412
+    return TagLib::String::UTF8;
413
+}
414
+
415
+TagLib::String::Type rccTaglibPatchGetID3Type() {
416
+#ifdef HAVE_LIBRCC
417
+    size_t len;
418
+    const char *charset;
419
+
420
+    rccTaglibPatchTryInit();
421
+
422
+    charset = rccGetCurrentCharsetName(ctx, ID3V2_CLASS);
423
+    if (charset) {
424
+	if (!strncmp(charset, "UTF", 3)) {
425
+	    len = strlen(charset);
426
+
427
+	    if (charset[len-1]=='8') return TagLib::String::UTF8;
428
+	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
429
+	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
430
+	    if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
431
+	}
432
+	return TagLib::String::Latin1ID3V2;
433
+    } else {
434
+	// Error or no-language configured: If Latin1ID3V2 is returned we normally will use the default unicode encoding unless Latin1 is selected by taglib
435
+	return TagLib::String::Latin1ID3V2;
436
+    }
437
+#endif /* HAVE_LIBRCC */
438
+    return TagLib::String::Latin1;
439
+}
440
diff --git a/taglib/toolkit/rccpatch.h b/taglib/toolkit/rccpatch.h
441
new file mode 100644
442
index 00000000..31f44106
443
--- /dev/null
444
+++ taglib/toolkit/rccpatch.h
445
@@ -0,0 +1,20 @@
446
+#ifndef _RCC_PATCH_H
447
+#define _RCC_PATCH_H
448
+
449
+#include <string.h>
450
+#include "tstring.h"
451
+#include "tbytevector.h"
452
+
453
+void rccTaglibPatchFree();
454
+void rccTaglibPatchInit();
455
+void rccTaglibPatchSetContext(void *newctx);
456
+
457
+TagLib::ByteVector rccTaglibPatchRecodeOutput(const std::string &s);
458
+TagLib::ByteVector rccTaglibPatchRecodeInput(const std::string &s);
459
+TagLib::ByteVector rccTaglibPatchRecodeOutputID3(const std::string &s, bool v2 = false);
460
+TagLib::ByteVector rccTaglibPatchRecodeInputID3(const std::string &s, bool v2 = false);
461
+
462
+TagLib::String::Type rccTaglibPatchGetLocaleType();
463
+TagLib::String::Type rccTaglibPatchGetID3Type();
464
+
465
+#endif /* _RCC_PATCH_H */
466
diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp
467
index 212c186f..690720ec 100644
468
--- taglib/toolkit/tstring.cpp
469
+++ taglib/toolkit/tstring.cpp
470
@@ -33,6 +33,7 @@
471
 #include <trefcounter.h>
472
 #include <tutils.h>
473
 
474
+#include "rccpatch.h"
475
 #include "tstring.h"
476
 
477
 namespace
478
@@ -47,14 +48,36 @@ namespace
479
     return String::UTF16BE;
480
   }
481
 
482
+  void copyFromUTF8(std::wstring &data, const char *s, size_t length);
483
+
484
   // Converts a Latin-1 string into UTF-16(without BOM/CPU byte order)
485
   // and copies it to the internal buffer.
486
-  void copyFromLatin1(std::wstring &data, const char *s, size_t length)
487
+  void copyFromLatin1(std::wstring &data, const char *s, size_t length, bool prepare = false, String::Type t = String::Latin1)
488
   {
489
     data.resize(length);
490
 
491
     for(size_t i = 0; i < length; ++i)
492
       data[i] = static_cast<unsigned char>(s[i]);
493
+
494
+
495
+    // librcc conversation
496
+    if (prepare) {
497
+
498
+     ByteVector v;
499
+     std::string str = std::string(s, length);
500
+
501
+     if (t == String::Latin1ID3) v = rccTaglibPatchRecodeInputID3(str, false);
502
+     else if (t == String::Latin1ID3V2) v = rccTaglibPatchRecodeInputID3(str, true);
503
+     else /* Latin1 converted from Locale */ v = rccTaglibPatchRecodeInput(str);
504
+
505
+     if (v.size()) {
506
+       copyFromUTF8(data, v.data(), v.size());
507
+     } else {
508
+     // We don't know if we got UTF-8 encoded string or either rcc is disable or something is failed,
509
+     // since standard applications are really expecting here Latin1, it is safe to just check if we have violations of UTF8
510
+     //if (Unicode::isLegalUTF8(s)) t = UTF8;
511
+     }
512
+    }
513
   }
514
 
515
   // Converts a UTF-8 string into UTF-16(without BOM/CPU byte order)
516
@@ -174,8 +197,11 @@ String::String(const String &s) :
517
 String::String(const std::string &s, Type t) :
518
   d(new StringPrivate())
519
 {
520
-  if(t == Latin1)
521
-    copyFromLatin1(d->data, s.c_str(), s.length());
522
+  if(t == Locale)
523
+   t = rccTaglibPatchGetLocaleType();
524
+
525
+  if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
526
+    copyFromLatin1(d->data, s.c_str(), s.length(), true, t);
527
   else if(t == String::UTF8)
528
     copyFromUTF8(d->data, s.c_str(), s.length());
529
   else {
530
@@ -222,8 +248,11 @@ String::String(const wchar_t *s, Type t) :
531
 String::String(const char *s, Type t) :
532
   d(new StringPrivate())
533
 {
534
-  if(t == Latin1)
535
-    copyFromLatin1(d->data, s, ::strlen(s));
536
+  if(t == Locale)
537
+    t = rccTaglibPatchGetLocaleType();
538
+
539
+  if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
540
+    copyFromLatin1(d->data, s, ::strlen(s), true, t);
541
   else if(t == String::UTF8)
542
     copyFromUTF8(d->data, s, ::strlen(s));
543
   else {
544
@@ -259,8 +288,12 @@ String::String(const ByteVector &v, Type t) :
545
   if(v.isEmpty())
546
     return;
547
 
548
-  if(t == Latin1)
549
-    copyFromLatin1(d->data, v.data(), v.size());
550
+  if(t == Locale)
551
+   t = rccTaglibPatchGetLocaleType();
552
+
553
+   if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2)
554
+     copyFromLatin1(d->data, v.data(), v.size(), true, t);
555
+
556
   else if(t == UTF8)
557
     copyFromUTF8(d->data, v.data(), v.size());
558
   else
559
@@ -412,8 +445,38 @@ bool String::isNull() const
560
 
561
 ByteVector String::data(Type t) const
562
 {
563
-  switch(t)
564
-  {
565
+  ByteVector v;
566
+
567
+  if (t == Locale) {
568
+        // The source is either Unicode or real Latin1 (if rcc is bypassed)
569
+    std::string s = to8Bit(true);
570
+
571
+        // In case of UTF8 locale, this probably will return NULL (no recoding needed), but we will take UTF8 path in the next swtich
572
+    v = rccTaglibPatchRecodeOutput(s);
573
+    if (v.size()) return v;
574
+
575
+    t = rccTaglibPatchGetLocaleType();
576
+  }
577
+
578
+  switch(t) {
579
+  case Latin1ID3:
580
+  case Latin1ID3V2:
581
+    {
582
+      std::string s = to8Bit(true);
583
+      if (t == Latin1ID3) v = rccTaglibPatchRecodeOutputID3(s, false);
584
+      else if (t == Latin1ID3V2) v = rccTaglibPatchRecodeOutputID3(s, true);
585
+      if (v.size())
586
+        return v;
587
+
588
+          // we don't know if we got NULL because rcc is disabled (error) or UTF8 output is required
589
+      if ((t == Latin1ID3V2)&&(rccTaglibPatchGetID3Type() == UTF8)) {
590
+          v.setData(s.c_str(), s.length());
591
+      } else {
592
+          for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
593
+            v.append(char(*it));
594
+      }
595
+      return v;
596
+    }
597
   case Latin1:
598
     {
599
       ByteVector v(size(), 0);
600
@@ -737,7 +800,33 @@ TagLib::String operator+(const TagLib::String &s1, const char *s2)
601
 
602
 std::ostream &operator<<(std::ostream &s, const TagLib::String &str)
603
 {
604
-  s << str.to8Bit();
605
+  TagLib::ByteVector bv = str.data(TagLib::String::Locale);
606
+  s << bv;
607
   return s;
608
 }
609
 
610
+TagLib::String::Type TagLib::String::ID3Type(int i)
611
+{
612
+  if(i == Latin1)
613
+    return Latin1ID3V2;
614
+  return Type(i);
615
+};
616
+
617
+TagLib::String::Type TagLib::String::ID3WType(Type type)
618
+{
619
+  Type rcc_type = rccTaglibPatchGetID3Type();
620
+  if((rcc_type == Latin1ID3)||(rcc_type == Latin1ID3V2)||(rcc_type == Latin1)) {
621
+    if(type == Latin1) return
622
+      rcc_type;
623
+    return type;
624
+  }
625
+
626
+  return rcc_type;
627
+};
628
+
629
+TagLib::String::Type TagLib::String::ID3RealType(Type type)
630
+{
631
+  if((type == Latin1ID3) || (type == Latin1ID3V2))
632
+    return Latin1;
633
+  return type;
634
+}
635
diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h
636
index e3853d80..b8eb70df 100644
637
--- taglib/toolkit/tstring.h
638
+++ taglib/toolkit/tstring.h
639
@@ -95,6 +95,18 @@ namespace TagLib {
640
      * ID3v1 is assumed to be Latin1 and Ogg Vorbis comments use UTF8.
641
      */
642
     enum Type {
643
+      /*!
644
+       * Determine using current locale settings
645
+       */
646
+      Locale = -1,
647
+      /*!
648
+       * Latin1 for ID3 tags.
649
+       */
650
+      Latin1ID3 = 65,
651
+      /*!
652
+       * Latin1 for ID3v2 tags.
653
+       */
654
+      Latin1ID3V2 = 66,
655
       /*!
656
        * IS08859-1, or <i>Latin1</i> encoding.  8 bit characters.
657
        */
658
@@ -118,6 +130,10 @@ namespace TagLib {
659
       UTF16LE = 4
660
     };
661
 
662
+    static Type ID3Type(int i);
663
+    static Type ID3WType(Type type);
664
+    static Type ID3RealType(Type type);
665
+
666
     /*!
667
      * Constructs an empty String.
668
      */
(-)b/audio/taglib/pkg-plist (-8 / +17 lines)
Lines 15-20 include/taglib/attachedpictureframe.h Link Here
15
include/taglib/audioproperties.h
15
include/taglib/audioproperties.h
16
include/taglib/chapterframe.h
16
include/taglib/chapterframe.h
17
include/taglib/commentsframe.h
17
include/taglib/commentsframe.h
18
include/taglib/dsdiffdiintag.h
19
include/taglib/dsdifffile.h
20
include/taglib/dsdiffproperties.h
21
include/taglib/dsffile.h
22
include/taglib/dsfproperties.h
18
include/taglib/eventtimingcodesframe.h
23
include/taglib/eventtimingcodesframe.h
19
include/taglib/fileref.h
24
include/taglib/fileref.h
20
include/taglib/flacfile.h
25
include/taglib/flacfile.h
Lines 43-48 include/taglib/mp4atom.h Link Here
43
include/taglib/mp4coverart.h
48
include/taglib/mp4coverart.h
44
include/taglib/mp4file.h
49
include/taglib/mp4file.h
45
include/taglib/mp4item.h
50
include/taglib/mp4item.h
51
include/taglib/mp4itemfactory.h
46
include/taglib/mp4properties.h
52
include/taglib/mp4properties.h
47
include/taglib/mp4tag.h
53
include/taglib/mp4tag.h
48
include/taglib/mpcfile.h
54
include/taglib/mpcfile.h
Lines 60-66 include/taglib/ownershipframe.h Link Here
60
include/taglib/podcastframe.h
66
include/taglib/podcastframe.h
61
include/taglib/popularimeterframe.h
67
include/taglib/popularimeterframe.h
62
include/taglib/privateframe.h
68
include/taglib/privateframe.h
63
%%RCC%%include/taglib/rccpatch.h
64
include/taglib/relativevolumeframe.h
69
include/taglib/relativevolumeframe.h
65
include/taglib/rifffile.h
70
include/taglib/rifffile.h
66
include/taglib/s3mfile.h
71
include/taglib/s3mfile.h
Lines 72-78 include/taglib/tableofcontentsframe.h Link Here
72
include/taglib/tag.h
77
include/taglib/tag.h
73
include/taglib/tag_c.h
78
include/taglib/tag_c.h
74
include/taglib/taglib.h
79
include/taglib/taglib.h
75
include/taglib/taglib_config.h
76
include/taglib/taglib_export.h
80
include/taglib/taglib_export.h
77
include/taglib/tbytevector.h
81
include/taglib/tbytevector.h
78
include/taglib/tbytevectorlist.h
82
include/taglib/tbytevectorlist.h
Lines 86-97 include/taglib/tlist.h Link Here
86
include/taglib/tlist.tcc
90
include/taglib/tlist.tcc
87
include/taglib/tmap.h
91
include/taglib/tmap.h
88
include/taglib/tmap.tcc
92
include/taglib/tmap.tcc
93
include/taglib/tpicturetype.h
89
include/taglib/tpropertymap.h
94
include/taglib/tpropertymap.h
90
include/taglib/trefcounter.h
91
include/taglib/trueaudiofile.h
95
include/taglib/trueaudiofile.h
92
include/taglib/trueaudioproperties.h
96
include/taglib/trueaudioproperties.h
93
include/taglib/tstring.h
97
include/taglib/tstring.h
94
include/taglib/tstringlist.h
98
include/taglib/tstringlist.h
99
include/taglib/tvariant.h
100
include/taglib/tversionnumber.h
95
include/taglib/uniquefileidentifierframe.h
101
include/taglib/uniquefileidentifierframe.h
96
include/taglib/unknownframe.h
102
include/taglib/unknownframe.h
97
include/taglib/unsynchronizedlyricsframe.h
103
include/taglib/unsynchronizedlyricsframe.h
Lines 106-118 include/taglib/xingheader.h Link Here
106
include/taglib/xiphcomment.h
112
include/taglib/xiphcomment.h
107
include/taglib/xmfile.h
113
include/taglib/xmfile.h
108
include/taglib/xmproperties.h
114
include/taglib/xmproperties.h
115
lib/cmake/taglib/taglib-config-version.cmake
116
lib/cmake/taglib/taglib-config.cmake
117
lib/cmake/taglib/taglib-targets-%%CMAKE_BUILD_TYPE%%.cmake
118
lib/cmake/taglib/taglib-targets.cmake
109
%%STATIC%%lib/libtag.a
119
%%STATIC%%lib/libtag.a
110
%%NO_STATIC%%lib/libtag.so
120
%%NO_STATIC%%lib/libtag.so
111
%%NO_STATIC%%lib/libtag.so.1
121
%%NO_STATIC%%lib/libtag.so.2
112
%%NO_STATIC%%lib/libtag.so.1.19.1
122
%%NO_STATIC%%lib/libtag.so.2.0.1
113
%%STATIC%%lib/libtag_c.a
123
%%STATIC%%lib/libtag_c.a
114
%%NO_STATIC%%lib/libtag_c.so
124
%%NO_STATIC%%lib/libtag_c.so
115
%%NO_STATIC%%lib/libtag_c.so.0
125
%%NO_STATIC%%lib/libtag_c.so.2
116
%%NO_STATIC%%lib/libtag_c.so.0.0.0
126
%%NO_STATIC%%lib/libtag_c.so.2.0.1
117
libdata/pkgconfig/taglib.pc
127
libdata/pkgconfig/taglib.pc
118
libdata/pkgconfig/taglib_c.pc
128
libdata/pkgconfig/taglib_c.pc
119
- 

Return to bug 276677