1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
diff -dPNur libguess-0.2.0-d7/guess.c libguess-0.2.0-d7-new/guess.c
--- libguess-0.2.0-d7/guess.c 2006-12-05 17:59:32.000000000 +0100
+++ libguess-0.2.0-d7-new/guess.c 2007-06-26 19:56:59.000000000 +0200
@@ -44,7 +44,7 @@
/* ORDER_** &highest, &second, ... &lowest */
#define ORDER_JP &utf8, &sjis, &eucj
#define ORDER_TW &utf8, &big5
-#define ORDER_CN &utf8, &gb2312, &gb18030
+#define ORDER_CN &utf8, &gb2312, &gb18030, &big5
#define ORDER_KR &utf8, &euck, &johab
/* workaround for that glib's g_convert can't convert
@@ -252,6 +252,8 @@
guess_dfa gb2312 = DFA_INIT(guess_gb2312_st, guess_gb2312_ar);
guess_dfa utf8 = DFA_INIT(guess_utf8_st, guess_utf8_ar);
guess_dfa gb18030 = DFA_INIT(guess_gb18030_st, guess_gb18030_ar);
+ guess_dfa big5 = DFA_INIT(guess_big5_st, guess_big5_ar);
+
guess_dfa *top = NULL;
guess_dfa *order[] = { ORDER_CN, NULL };
@@ -287,22 +289,27 @@
}
if (DFA_ALIVE(gb2312)) {
- if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030))
+ if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030) && !DFA_ALIVE(big5))
return "GB2312";
DFA_NEXT(gb2312, c);
}
if (DFA_ALIVE(utf8)) {
- if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(gb18030))
+ if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(gb18030) && !DFA_ALIVE(big5))
return "UTF-8";
DFA_NEXT(utf8, c);
}
if (DFA_ALIVE(gb18030)) {
- if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb2312))
+ if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb2312) && !DFA_ALIVE(big5))
return "GB18030";
DFA_NEXT(gb18030, c);
}
+ if (DFA_ALIVE(big5)) {
+ if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb2312) && !DFA_ALIVE(gb18030))
+ return "big5";
+ DFA_NEXT(big5, c);
+ }
- if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030)) {
+ if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030) && !DFA_ALIVE(big5)) {
/* we ran out the possibilities */
return NULL;
}
@@ -323,6 +330,8 @@
return "UTF-8";
if (top == &gb18030)
return "GB18030";
+ if (top == &big5)
+ return "BIG5";
return NULL;
}
|