-
Notifications
You must be signed in to change notification settings - Fork 4
/
ibm866.go
34 lines (28 loc) · 815 Bytes
/
ibm866.go
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
package cpd
//unit for ibm866
// for CP866 calculate only count of letter from table 'tbl'
func match866(data []byte, tbl *cpTable) MatchRes {
for i := range data {
j := tbl.index(rune(data[i])) //return 0 if rune data[i] not found
(*tbl)[j].count++
}
return MatchRes{tbl.founded(), 0}
}
const (
cp866StartUpperChar = 0x80
cp866StopUpperChar = 0x9F
cp866BeginLowerChar1 = 0xA0
cp866StopLowerChar1 = 0xAF
cp866BeginLowerChar2 = 0xE0
cp866StopLowerChar2 = 0xEF
)
func isUpper866(r byte) bool {
return (r >= cp866StartUpperChar) && (r <= cp866StopUpperChar)
}
func isLower866(r byte) bool {
return ((r >= cp866BeginLowerChar1) && (r <= cp866StopLowerChar1)) ||
((r >= cp866BeginLowerChar2) && (r <= cp866StopLowerChar2))
}
func is866(r byte) bool {
return isUpper866(r) || isLower866(r)
}