File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright 2016 GitHub Inc.
3
+ See https://github.com/github/gh-ost/blob/master/LICENSE
4
+ */
5
+
6
+ package sql
7
+
8
+ import (
9
+ "golang.org/x/text/encoding"
10
+ "golang.org/x/text/encoding/charmap"
11
+ )
12
+
13
+ type charsetEncoding map [string ]encoding.Encoding
14
+
15
+ var charsetEncodingMap charsetEncoding
16
+
17
+ func init () {
18
+ charsetEncodingMap = make (map [string ]encoding.Encoding )
19
+ // Begin mappings
20
+ charsetEncodingMap ["latin1" ] = charmap .Windows1252
21
+ }
Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ import (
10
10
"reflect"
11
11
"strconv"
12
12
"strings"
13
-
14
- "golang.org/x/text/encoding/charmap"
15
13
)
16
14
17
15
type Column struct {
@@ -22,9 +20,9 @@ type Column struct {
22
20
23
21
func (this * Column ) convertArg (arg interface {}) interface {} {
24
22
if s , ok := arg .(string ); ok {
25
- switch this . Charset {
26
- case "latin1" :
27
- arg , _ = charmap . Windows1252 .NewDecoder ().String (s )
23
+ // string, charset conversion
24
+ if encoding , ok := charsetEncodingMap [ this . Charset ]; ok {
25
+ arg , _ = encoding .NewDecoder ().String (s )
28
26
}
29
27
return arg
30
28
}
You can’t perform that action at this time.
0 commit comments