1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 02-japanese_charset.dpatch by <fm4j-kbys@asahi-net.or.jp>
4
## All lines beginning with `## DP:' are a description of the patch.
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
12
-/* Time-stamp: <2006-05-01 15:04:54 jcs>
13
+/* Time-stamp: <13-d�c-2006 22:39:02 seb128>
15
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
16
| Part of the gtkpod project.
19
static const gchar *charset_check_k_code (const gchar *p2)
21
- guchar *p = (guchar *)p2;
22
+ static const char* charsets[] = {
33
- while (p && *p && (*p != '\n'))
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))))
48
+ if (p2 == NULL) return NULL;
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 */
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)
72
const gchar *result=NULL;
74
if (p) result = charset_check_k_code (p);
75
- if (!result) result = "EUC-JP";
76
+ if (!result) result = "UTF-8";
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)