Sybase Adaptive Server
Enterprise在中文支持方面,提供的排序方式比較單一。如果使用CP850(支持GB2312標準),排序方式是比較多的。但GB2312的漢字
庫太小,多數(shù)情況下,我們至少要使用CP936甚至GB18030字符集。在使用CP936、GB18030字符集時,你只有BINARY方式的排序可以
選擇。
問題是,如果一個早期應(yīng)該使用CP850+大小寫不敏感方式的排序,在升級到新的字符集+BINARY排序時,程序中的大小寫要改成敏感的。
類似的問題可以通過修改SYBASE的相應(yīng)字符集下的排序文件解決。你甚至可以定義自己的排序方式。
首先我們來看看GB18030字符集的BINARY排序。BINARY排序?qū)?yīng)的是$SYB_HOME/charsets/gb18030/binary.srt,用文本編輯器打開這個文件,可以看到其內(nèi)容如下:
Class、id、name、menuname、charset、description都不用修改,而binary=true則指明使用binary方式排序,其實這句等價于對01~FF每個字符都進行定義。
其 次,看一下其他字符集中的大小寫不敏感的排序文件,如$SYB_HOME/charsets/iso_1/noaccents.srt,具體內(nèi)容就不寫 了。可以發(fā)現(xiàn)大小寫不敏感只是設(shè)置a, A;b, B等字符相等。參考這個排序文件,我們就可以這樣定義binary.srt:
1. 設(shè)置a=A...z=Z;
2. 定義其他字符。
這樣修改之后,就支持GB18030下的大小寫不敏感排序了。
修改排序文件后,需要使用加裁該字符集和排序:
charset -Usa -Ppassword -Sserver sort_order_file charset_name
然后在isql中用sp_configure 'default sortorder id', 文件中的id(十進制),兩次重啟SYBASE后修改字符集排序就完成了。
這種方法適用于ASE11.9.2~15.0各個版本,經(jīng)歷了實踐考驗。
另外對于早期版本,沒有CP936和GB18030,可以從15.0拷一個過去用。
下面附上我修改的GB18030, BINARY.SRT文件內(nèi)容:
問題是,如果一個早期應(yīng)該使用CP850+大小寫不敏感方式的排序,在升級到新的字符集+BINARY排序時,程序中的大小寫要改成敏感的。
類似的問題可以通過修改SYBASE的相應(yīng)字符集下的排序文件解決。你甚至可以定義自己的排序方式。
首先我們來看看GB18030字符集的BINARY排序。BINARY排序?qū)?yīng)的是$SYB_HOME/charsets/gb18030/binary.srt,用文本編輯器打開這個文件,可以看到其內(nèi)容如下:
1
; semi-colon is the comment character
2
[sortorder]
3
;===============================================================================
4
;
5
; Sort Order Overview:
6
; --------------------
7
; Based on the gb18030 simplified Chinese character set, this sort
8
; order is a binary ordering.
9
;
10
;===============================================================================
11
12
class = 0x01 ; Class `1' sort order
13
id = 0x32 ; id = 50
14
name = bin_gb18030
15
menuname = "Binary ordering, for gb18030."
16
charset = gb18030
17
18
description = "Binary sort order for simplified Chinese using gb18030."
19
20
binary = "true"
21

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

Class、id、name、menuname、charset、description都不用修改,而binary=true則指明使用binary方式排序,其實這句等價于對01~FF每個字符都進行定義。
其 次,看一下其他字符集中的大小寫不敏感的排序文件,如$SYB_HOME/charsets/iso_1/noaccents.srt,具體內(nèi)容就不寫 了。可以發(fā)現(xiàn)大小寫不敏感只是設(shè)置a, A;b, B等字符相等。參考這個排序文件,我們就可以這樣定義binary.srt:
1. 設(shè)置a=A...z=Z;
2. 定義其他字符。
這樣修改之后,就支持GB18030下的大小寫不敏感排序了。
修改排序文件后,需要使用加裁該字符集和排序:
charset -Usa -Ppassword -Sserver sort_order_file charset_name
然后在isql中用sp_configure 'default sortorder id', 文件中的id(十進制),兩次重啟SYBASE后修改字符集排序就完成了。
這種方法適用于ASE11.9.2~15.0各個版本,經(jīng)歷了實踐考驗。
另外對于早期版本,沒有CP936和GB18030,可以從15.0拷一個過去用。
下面附上我修改的GB18030, BINARY.SRT文件內(nèi)容:
1
; semi-colon is the comment character
2
[sortorder]
3
;===============================================================================
4
;
5
; Sort Order Overview:
6
; --------------------
7
; Based on the cp936 simplified Chinese character set, this sort
8
; order is a binary ordering.
9
;
10
;===============================================================================
11
12
class = 0x01 ; Class `1' sort order
13
id = 0x32 ; id = 50
14
name = bin_gb18030
15
menuname = "Binary ordering, for gb18030."
16
charset = gb18030
17
;preference = false ; Do not use preference
18
19
description = "Binary sort order for simplified Chinese using gb18030."
20
; Ligatures
21
22
;lig = 0xC6=0xE6, after ae ; AE, ae ligature
23
;lig = 0xDF, after ss ; small german letter sharp s
24
25
; Control characters
26
27
char = 0x01 ;(SOH) start of heading
28
char = 0x02 ;(STX) start of text
29
char = 0x03 ;(ETX) end of text
30
char = 0x04 ;(EOT) end of transmission
31
char = 0x05 ;(ENQ) enquiry
32
char = 0x06 ;(ACK) acknowledge
33
char = 0x07 ;(BEL) bell
34
char = 0x08 ;(BS) backspace
35
char = 0x09 ;(HT) horizontal tab
36
char = 0x0A ;(LF) newline, or line feed
37
char = 0x0B ;(VT) vertical tab
38
char = 0x0C ;(FF) form feed
39
char = 0x0D ;(CR) carriage return
40
char = 0x0E ;(SO) shift out
41
char = 0x0F ;(SI) shift in
42
char = 0x10 ;(DLE) data link escape
43
char = 0x11 ;(DC1) device control 1
44
char = 0x12 ;(DC2) device control 2
45
char = 0x13 ;(DC3) device control 3
46
char = 0x14 ;(DC4) device control 4
47
char = 0x15 ;(NAK) negative acknowledge
48
char = 0x16 ;(SYN) synchronous idle
49
char = 0x17 ;(ETB) end transmission blk
50
char = 0x18 ;(CAN) cancel
51
char = 0x19 ;(EM) end of medium
52
char = 0x1A ;(SUB) substitute
53
char = 0x1B ;(ESC) escape
54
char = 0x1C ;(FS) file separator
55
char = 0x1D ;(GS) group separator
56
char = 0x1E ;(RS) record separator
57
char = 0x1F ;(US) unit separator
58
59
; All non-alphanumeric characters, including puntuation
60
; These are sorted merely by their numerical ordering
61
; based on the ISO 8859-1 standard for clarity and
62
; consistency
63
64
char = 0x20 ;( ) space
65
char = 0x21 ;(!) exclamation mark
66
char = 0x22 ;(") quotation mark
67
char = 0x23 ;(#) number sign
68
char = 0x24 ;($) dollar sign
69
char = 0x25 ;(%) percent sign
70
char = 0x26 ;(&) ampersand
71
char = 0x27 ;(') apostrophe
72
char = 0x28 ;(() left parenthesis
73
char = 0x29 ;()) right parenthesis
74
char = 0x2A ;(*) asterisk
75
char = 0x2B ;(+) plus sign
76
char = 0x2C ;(,) comma
77
char = 0x2D ;(-) hyphen, minus sign
78
char = 0x2E ;(.) full stop
79
char = 0x2F ;(/) solidus
80
char = 0x3A ;(:) colon
81
char = 0x3B ;(;) semicolon
82
char = 0x3C ;(<) less-than sign
83
char = 0x3D ;(=) equals sign
84
char = 0x3E ;(>) greater-than sign
85
char = 0x3F ;(?) question mark
86
char = 0x40 ;(@) commercial at
87
char = 0x5B ;([) left square bracket
88
char = 0x5C ;(\) reverse solidus
89
char = 0x5D ;(]) right square bracket
90
char = 0x5E ;(^) circumflex accent
91
char = 0x5F ;(_) low line
92
char = 0x60 ;(`) grave accent
93
char = 0x7B ;({) left curly bracket
94
char = 0x7C ;(|) vertical line
95
char = 0x7D ;(}) right curly bracket
96
char = 0x7E ;(~) tilde
97
char = 0x7F ;delete, or rubout
98
char = 0x80 ; undefined
99
char = 0x81 ; undefined
100
char = 0x82 ; undefined
101
char = 0x83 ; undefined
102
char = 0x84 ; undefined
103
char = 0x85 ; undefined
104
char = 0x86 ; undefined
105
char = 0x87 ; undefined
106
char = 0x88 ; undefined
107
char = 0x89 ; undefined
108
char = 0x8A ; undefined
109
char = 0x8B ; undefined
110
char = 0x8C ; undefined
111
char = 0x8D ; undefined
112
char = 0x8E ; undefined
113
char = 0x8F ; undefined
114
char = 0x90 ; undefined
115
char = 0x91 ; undefined
116
char = 0x92 ; undefined
117
char = 0x93 ; undefined
118
char = 0x94 ; undefined
119
char = 0x95 ; undefined
120
char = 0x96 ; undefined
121
char = 0x97 ; undefined
122
char = 0x98 ; undefined
123
char = 0x99 ; undefined
124
char = 0x9A ; undefined
125
char = 0x9B ; undefined
126
char = 0x9C ; undefined
127
char = 0x9D ; undefined
128
char = 0x9E ; undefined
129
char = 0x9F ; undefined
130
char = 0xA0 ;no-break space
131
char = 0xA1 ;inverted exclamation mark
132
char = 0xA2 ;cent sign
133
char = 0xA3 ;pound sign
134
char = 0xA4 ;currency sign
135
char = 0xA5 ;yen sign
136
char = 0xA6 ;broken bar
137
char = 0xA7 ;paragraph sign, section sign
138
char = 0xA8 ;diaeresis
139
char = 0xA9 ;copyright sign
140
char = 0xAA ;feminine ordinal indicator
141
char = 0xAB ;left angle quotation mark
142
char = 0xAC ;not sign
143
char = 0xAD ;soft hyphen
144
char = 0xAE ;registered trade mark sign
145
char = 0xAF ;macron
146
char = 0xB0 ;ring above or degree sign
147
char = 0xB1 ;plus/minus (+/-) sign
148
char = 0xB2 ;superscript 2
149
char = 0xB3 ;superscript 3
150
char = 0xB4 ;acute accent
151
char = 0xB5 ;micro sign
152
char = 0xB6 ;pilcrow or paragraph sign
153
char = 0xB7 ;middle dot
154
char = 0xB8 ;cedilla
155
char = 0xB9 ;superscript 1
156
char = 0xBA ;masculine ordinal indicator
157
char = 0xBB ;right angle quotation mark
158
char = 0xBC ;vulgar fraction one quarter
159
char = 0xBD ;vulgar fraction one half
160
char = 0xBE ;vulgar fraction three quarter
161
char = 0xBF ;inverted question mark
162
char = 0xC0
163
char = 0xC1
164
char = 0xC2
165
char = 0xC3
166
char = 0xC4
167
char = 0xC5
168
char = 0xC6
169
char = 0xC7
170
char = 0xC8
171
char = 0xC9
172
char = 0xCA
173
char = 0xCB
174
char = 0xCC
175
char = 0xCD
176
char = 0xCE
177
char = 0xCF
178
char = 0xD0
179
char = 0xD1
180
char = 0xD2
181
char = 0xD3
182
char = 0xD4
183
char = 0xD5
184
char = 0xD6
185
char = 0xD7 ;multiplication sign
186
char = 0xD8
187
char = 0xD9
188
char = 0xDA
189
char = 0xDB
190
char = 0xDC
191
char = 0xDD
192
char = 0xDE
193
char = 0xDF
194
char = 0xE0
195
char = 0xE1
196
char = 0xE2
197
char = 0xE3
198
char = 0xE4
199
char = 0xE5
200
char = 0xE6
201
char = 0xE7
202
char = 0xE8
203
char = 0xE9
204
char = 0xEA
205
char = 0xEB
206
char = 0xEC
207
char = 0xED
208
char = 0xEE
209
char = 0xEF
210
char = 0xF0
211
char = 0xF1
212
char = 0xF2
213
char = 0xF3
214
char = 0xF4
215
char = 0xF5
216
char = 0xF6
217
char = 0xF7
218
char = 0xF8
219
char = 0xF9
220
char = 0xFA
221
char = 0xFB
222
char = 0xFC
223
char = 0xFD
224
char = 0xFE
225
char = 0xFF
226
227
; Digits
228
229
char = 0x30 ;(0) digit zero
230
char = 0x31 ;(1) digit one
231
char = 0x32 ;(2) digit two
232
char = 0x33 ;(3) digit three
233
char = 0x34 ;(4) digit four
234
char = 0x35 ;(5) digit five
235
char = 0x36 ;(6) digit six
236
char = 0x37 ;(7) digit seven
237
char = 0x38 ;(8) digit eight
238
char = 0x39 ;(9) digit nine
239
240
; Latin Alphabet
241
242
char = 0x41=0x61
243
;A, a, A-grave, a-grave, A-acute, a-acute, A-circumflex, a-circumflex,
244
;A-tilde, a-tilde, ;A-diaeresis, a-diaeresis, A-ring, a-ring
245
char = 0x42=0x62 ;letter B, b
246
char = 0x43=0x63
247
char = 0x44=0x64 ;letter D, d
248
char = 0x45=0x65
249
;E, e, E-grave, e-grave, E-acute, e-acute, E-circumflex, e-circumflex,
250
;E-diaeresis, e-diaeresis
251
char = 0x46=0x66 ;letter F, f
252
char = 0x47=0x67 ;letter G, g
253
char = 0x48=0x68 ;letter H, h
254
char = 0x49=0x69
255
;I, i, I-grave, i-grave, I-acute, i-acute, I-circumflex, i-circumflex,
256
;I-diaeresis, i-diaeresis
257
char = 0x4A=0x6A ;letter J, j
258
char = 0x4B=0x6B ;letter K, k
259
char = 0x4C=0x6C ;letter L, l
260
char = 0x4D=0x6D ;letter M, m
261
char = 0x4E=0x6E
262
char = 0x4F=0x6F
263
;O, o, O-grave, o-grave, O-acute, o-acute, O-circumflex, o-circumflex,
264
;O-tilde, o-tilde, O-diaeresis, o-diaeresis, O-stroke, o-stroke
265
char = 0x50=0x70 ;letter P, p
266
char = 0x51=0x71 ;letter Q, q
267
char = 0x52=0x72 ;letter R, r
268
char = 0x53=0x73 ;letter S, s
269
char = 0x54=0x74 ;letter T, t
270
char = 0x55=0x75
271
;U, u, U-grave, u-grave, U-acute, u-acute, U-circumflex, u-circumflex,
272
;U-diaeresis, u-diaeresis
273
char = 0x56=0x76 ;letter V, v
274
char = 0x57=0x77 ;letter W, w
275
char = 0x58=0x78 ;letter X, x
276
char = 0x59=0x79
277
char = 0x5A=0x7A ;letter Z, z
278
279
; Alpha characters not used in English, French or German:
280
281
;char = 0xD0=0xF0 ;icelandic capital letter eth, small letter eth
282
;char = 0xDE=0xFE ;icelandic capital letter thorn, small letter thorn
283

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

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283
