~ubuntu-branches/ubuntu/maverick/vdr-plugin-mp3/maverick

« back to all changes in this revision

Viewing changes to debian/patches/01_mp3-ogg-conv-utf8.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Tobias Grimm
  • Date: 2010-03-28 15:09:21 UTC
  • mfrom: (2.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100328150921-3kti802cqh0pe1hl
Tags: 0.10.2-3
* Build-depend on vdr-dev >= 1.6.0-16
* Minor debian/copyright update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run 
2
 
## 01_mp3-ogg-conv-utf8.dpatch by Thomas G�nther <tom@toms-cafe.de>
3
 
## http://toms-cafe.de/vdr/download/mp3-0.10.0-ogg-conv-utf8.diff
4
 
##
5
 
## All lines beginning with `## DP:' are a description of the patch.
6
 
## DP: Converts ogginfos from utf8 to the setup charset.
7
 
 
8
 
@DPATCH@
9
 
--- mp3-0.10.0/decoder-ogg.c
10
 
+++ mp3-0.10.0/decoder-ogg.c
11
 
@@ -28,6 +28,32 @@
12
 
 #include "common.h"
13
 
 #include "decoder-ogg.h"
14
 
 
15
 
+#include <vdr/config.h>
16
 
+#include <vdr/i18n.h>
17
 
+#include <iconv.h>
18
 
+static char *ConvertFromUTF8(const char *text)
19
 
+{
20
 
+  if (!text) return NULL;
21
 
+  char *buffer = strdup(text);
22
 
+#if APIVERSNUM >= 10503
23
 
+  iconv_t ic = iconv_open(cCharSetConv::SystemCharacterTable(), "UTF8");
24
 
+#else
25
 
+  iconv_t ic = iconv_open(I18nCharSets()[Setup.OSDLanguage], "UTF8");
26
 
+#endif
27
 
+  if (ic >= 0) {
28
 
+     char *in = (char *)text;
29
 
+     char *out = buffer;
30
 
+     size_t inbytesleft = strlen(text);
31
 
+     size_t outbytesleft = inbytesleft;
32
 
+     if (iconv(ic, &in, &inbytesleft, &out, &outbytesleft) != (size_t)(-1))
33
 
+        *out = 0;
34
 
+     else
35
 
+        strcpy(buffer, text);
36
 
+     iconv_close(ic);
37
 
+     }
38
 
+  return buffer;
39
 
+}
40
 
+
41
 
 // --- cOggFile ----------------------------------------------------------------
42
 
 
43
 
 cOggFile::cOggFile(const char *Filename)
44
 
@@ -166,13 +192,13 @@
45
 
         const int len=p-cc;
46
 
         p++;
47
 
         if(!strncasecmp(cc,"TITLE",len)) {
48
 
-          if(!Title) Title=strdup(p);
49
 
+          if(!Title) Title=ConvertFromUTF8(p);
50
 
           }
51
 
         else if(!strncasecmp(cc,"ARTIST",len)) {
52
 
-          if(!Artist) Artist=strdup(p);
53
 
+          if(!Artist) Artist=ConvertFromUTF8(p);
54
 
           }
55
 
         else if(!strncasecmp(cc,"ALBUM",len)) {
56
 
-          if(!Album) Album=strdup(p);
57
 
+          if(!Album) Album=ConvertFromUTF8(p);
58
 
           }
59
 
         else if(!strncasecmp(cc,"YEAR",len)) {
60
 
           if(Year<0) {