|
@@ -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"
|
|
@@ -444,19 +445,17 @@ func (c *HisApiController) GetBasBaseInfo() string {
|
444
|
445
|
fmt.Println("readcard is nil")
|
445
|
446
|
readCard = DllDef.MustFindProc("ReadCardBas")
|
446
|
447
|
}
|
447
|
|
-
|
448
|
448
|
str := make([]byte, 1024)
|
449
|
449
|
str1 := make([]byte, 1024)
|
450
|
450
|
ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
|
451
|
|
-
|
452
|
451
|
fmt.Println(string(str1))
|
453
|
452
|
fmt.Println(string(str))
|
454
|
|
-
|
|
453
|
+ fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
|
|
454
|
+ fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
|
455
|
455
|
if ret2 != 0 {
|
456
|
456
|
return ""
|
457
|
457
|
}
|
458
|
458
|
return string(str)
|
459
|
|
-
|
460
|
459
|
}
|
461
|
460
|
|
462
|
461
|
func prttostr(vcode uintptr) string {
|
|
@@ -6799,3 +6798,19 @@ func saveLog(result string, request string, infno string, desc string) {
|
6799
|
6798
|
}
|
6800
|
6799
|
|
6801
|
6800
|
}
|
|
6801
|
+
|
|
6802
|
+type Charset string
|
|
6803
|
+
|
|
6804
|
+const (
|
|
6805
|
+ UTF8 = Charset("UTF-8")
|
|
6806
|
+ GB18030 = Charset("GB18030")
|
|
6807
|
+)
|
|
6808
|
+
|
|
6809
|
+func ConvertToString(src string, srcCode string, tagCode string) string {
|
|
6810
|
+ srcCoder := mahonia.NewDecoder(srcCode)
|
|
6811
|
+ srcResult := srcCoder.ConvertString(src)
|
|
6812
|
+ tagCoder := mahonia.NewDecoder(tagCode)
|
|
6813
|
+ _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
|
|
6814
|
+ result := string(cdata)
|
|
6815
|
+ return result
|
|
6816
|
+}
|