-
Notifications
You must be signed in to change notification settings - Fork 1
/
encoder.go
39 lines (35 loc) · 856 Bytes
/
encoder.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
35
36
37
38
39
/*
* Bamboo - A Vietnamese Input method editor
* Copyright (C) Luong Thanh Lam <ltlam93@gmail.com>
*
* This software is licensed under the MIT license. For more information,
* see <https://github.com/BambooEngine/bamboo-core/blob/master/LICENSE>.
*/
package bamboo
const UNICODE = "Unicode"
func Encode(charsetName string, input string) string {
if charsetName == UNICODE {
return input
}
var output string
if charset, found := charsetDefinitions[charsetName]; found {
for _, chr := range input {
if out, found := charset[chr]; found {
output = output + out
} else {
output = output + string(chr)
}
}
} else {
output = input
}
return output
}
func GetCharsetNames() []string {
var names []string
names = append(names, UNICODE)
for cs := range charsetDefinitions {
names = append(names, cs)
}
return names
}