Browse Source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 4 years ago
parent
commit
d1d01526f3
1 changed files with 9 additions and 8 deletions
  1. 9 8
      controllers/sz/sz_his_api_controller.go

+ 9 - 8
controllers/sz/sz_his_api_controller.go View File

@@ -9,6 +9,7 @@ import (
9 9
 	"gdyb/service"
10 10
 	"gdyb/utils"
11 11
 	"github.com/astaxie/beego"
12
+	"github.com/axgle/mahonia"
12 13
 	"math/rand"
13 14
 
14 15
 	//"github.com/axgle/mahonia"
@@ -3820,11 +3821,11 @@ const (
3820 3821
 	GB18030 = Charset("GB18030")
3821 3822
 )
3822 3823
 
3823
-//func ConvertToString(src string, srcCode string, tagCode string) string {
3824
-//	srcCoder := mahonia.NewDecoder(srcCode)
3825
-//	srcResult := srcCoder.ConvertString(src)
3826
-//	tagCoder := mahonia.NewDecoder(tagCode)
3827
-//	_, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
3828
-//	result := string(cdata)
3829
-//	return result
3830
-//}
3824
+func ConvertToString(src string, srcCode string, tagCode string) string {
3825
+	srcCoder := mahonia.NewDecoder(srcCode)
3826
+	srcResult := srcCoder.ConvertString(src)
3827
+	tagCoder := mahonia.NewDecoder(tagCode)
3828
+	_, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
3829
+	result := string(cdata)
3830
+	return result
3831
+}