|
@@ -11,6 +11,7 @@ import (
|
11
|
11
|
"gdyb/service"
|
12
|
12
|
"gdyb/utils"
|
13
|
13
|
"github.com/astaxie/beego"
|
|
14
|
+ "github.com/axgle/mahonia"
|
14
|
15
|
"github.com/jinzhu/gorm"
|
15
|
16
|
"github.com/shopspring/decimal"
|
16
|
17
|
"io"
|
|
@@ -443,11 +444,12 @@ func GetBasBaseInfo() (jsonStr string, err error) {
|
443
|
444
|
|
444
|
445
|
handle := syscall.MustLoadDLL("SSCard.dll")
|
445
|
446
|
add := handle.MustFindProc("ReadCardBas")
|
446
|
|
- str := make([]byte, 256)
|
447
|
|
- str1 := make([]byte, 256)
|
|
447
|
+ str := make([]byte, 1024)
|
|
448
|
+ str1 := make([]byte, 1024)
|
448
|
449
|
ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
|
449
|
450
|
fmt.Println(string(str))
|
450
|
|
- fmt.Println(string(str1))
|
|
451
|
+ fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
|
|
452
|
+
|
451
|
453
|
fmt.Println("> Add(4,5)的结果为:", ret)
|
452
|
454
|
return "", nil
|
453
|
455
|
|
|
@@ -4253,3 +4255,19 @@ func RemoveRepeatedCode(arr []string) (newArr []string) {
|
4253
|
4255
|
}
|
4254
|
4256
|
return
|
4255
|
4257
|
}
|
|
4258
|
+
|
|
4259
|
+type Charset string
|
|
4260
|
+
|
|
4261
|
+const (
|
|
4262
|
+ UTF8 = Charset("UTF-8")
|
|
4263
|
+ GB18030 = Charset("GB18030")
|
|
4264
|
+)
|
|
4265
|
+
|
|
4266
|
+func ConvertToString(src string, srcCode string, tagCode string) string {
|
|
4267
|
+ srcCoder := mahonia.NewDecoder(srcCode)
|
|
4268
|
+ srcResult := srcCoder.ConvertString(src)
|
|
4269
|
+ tagCoder := mahonia.NewDecoder(tagCode)
|
|
4270
|
+ _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
|
|
4271
|
+ result := string(cdata)
|
|
4272
|
+ return result
|
|
4273
|
+}
|