~ubuntu-branches/ubuntu/quantal/gtkpod-aac/quantal

« back to all changes in this revision

Viewing changes to debian/patches/02-japanese_charset.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-07-17 18:25:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070717182525-rhl5w4pk8lbk6pna
Tags: 0.99.10-2ubuntu1
* Resynchronise with gtkpod 0.9.10-2.
* Hack in dpatch support, since it was removed.
* Rename debian/patches/03-configure.dpatch to
  debian/patches/aac-configure.dpatch.
* Update debian/gtkpod-aac.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## 02-japanese_charset.dpatch by  <fm4j-kbys@asahi-net.or.jp>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
@DPATCH@
8
 
diff -urNad gtkpod-0.99.8~/src/charset.c gtkpod-0.99.8/src/charset.c
9
 
--- gtkpod-0.99.8~/src/charset.c        2006-06-25 18:08:33.000000000 +0200
10
 
+++ gtkpod-0.99.8/src/charset.c 2006-12-13 22:39:02.000000000 +0100
11
 
@@ -1,4 +1,4 @@
12
 
-/* Time-stamp: <2006-05-01 15:04:54 jcs>
13
 
+/* Time-stamp: <13-d�c-2006 22:39:02 seb128>
14
 
 |
15
 
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
16
 
 |  Part of the gtkpod project.
17
 
@@ -267,38 +267,46 @@
18
 
    Hiroshi Kawashima */
19
 
 static const gchar *charset_check_k_code (const gchar *p2)
20
 
 {
21
 
-    guchar *p = (guchar *)p2;
22
 
+    static const char* charsets[] = {
23
 
+           "UTF-8",
24
 
+           "EUC-JP",
25
 
+           "CP932",
26
 
+           "ISO-2022-JP",
27
 
+           NULL
28
 
+    };
29
 
+    int i;
30
 
+    gchar *ret;
31
 
+    gssize len;
32
 
 
33
 
-    while (p && *p && (*p != '\n'))
34
 
-    {
35
 
-       if ((p[0] == 0x1b) &&
36
 
-           p[1] && (p[1] == 0x24) &&
37
 
-           p[2] && (p[2] == 0x42))         return ("ISO-2022-JP");
38
 
-       if ((p[0] == 0x1b) &&
39
 
-           p[1] && (p[1] == 0x24) &&
40
 
-           p[2] && (p[2] == 0x40))         return ("ISO-2022-JP");
41
 
-       if (((p[0] >= 0x81) && (p[0] <= 0x9f)) ||
42
 
-           (p[0] >= 0xe0))                 return ("Shift_JIS");
43
 
-       if ((p[0] >= 0xa1) && (p[0] <= 0xfe) && p[1] &&
44
 
-           (((p[1] >= 0x21) && (p[1] <= 0x7e)) ||
45
 
-            ((p[1] >= 0xa1) && (p[1] <= 0xfe))))
46
 
-                                           return ("EUC-JP");
47
 
-       ++p;
48
 
+    if (p2 == NULL) return NULL;
49
 
50
 
+    len = strlen ((gchar*)p2);
51
 
+    for (i=0; charsets[i]; i++) {
52
 
+      ret = g_convert ((gchar*)p2,            /* string to convert */
53
 
+                      len,                  /* length of string  */
54
 
+                      "UTF-8",              /* to_codeset        */
55
 
+                      charsets[i],          /* from_codeset      */
56
 
+                      NULL,                 /* *bytes_read       */
57
 
+                      NULL,                 /* *bytes_written    */
58
 
+                      NULL);                /* GError **error    */
59
 
+      if (ret != NULL) {
60
 
+        g_free(ret);
61
 
+        return charsets[i];
62
 
+      }
63
 
     }
64
 
     return (NULL);
65
 
 }
66
 
 
67
 
-/* same as check_k_code, but defaults to "EUC-JP" if no match is found */
68
 
-static const gchar *charset_check_k_code_with_default (const gchar *p)
69
 
+/* same as check_k_code, but defaults to "UTF-8" if no match is found */
70
 
+static const gchar *charset_check_k_code_with_default (const guchar *p)
71
 
 {
72
 
     const gchar *result=NULL;
73
 
 
74
 
     if (p)       result = charset_check_k_code (p);
75
 
-    if (!result) result = "EUC-JP";
76
 
+    if (!result) result = "UTF-8";
77
 
     return result;
78
 
 }
79
 
 
80
 
-
81
 
 /* return the charset actually used for the "auto detection"
82
 
  * feature. So far only Japanese Auto Detecion is implemented */
83
 
 static gchar *charset_check_auto (const gchar *str)