Export ToUC function and update test code

This commit is contained in:
vcaesar 2021-08-19 14:03:11 -04:00
parent 58057ea219
commit 45251144e5
2 changed files with 7 additions and 5 deletions

View File

@ -75,7 +75,7 @@ import (
const (
// Version get the robotgo version
Version = "v0.93.1.1189, MT. Rainier!"
Version = "v0.99.1.1189, MT. Rainier!"
)
// GetVersion get the robotgo version
@ -730,7 +730,8 @@ func UnicodeType(str uint32) {
C.unicodeType(cstr)
}
func toUC(text string) []string {
// ToUC trans string to unicode []string
func ToUC(text string) []string {
var uc []string
for _, r := range text {
@ -768,7 +769,7 @@ func TypeStr(str string, args ...float64) {
}
if runtime.GOOS == "linux" {
strUc := toUC(str)
strUc := ToUC(str)
for i := 0; i < len(strUc); i++ {
ru := []rune(strUc[i])
if len(ru) <= 1 {

View File

@ -126,8 +126,9 @@ func TestTypeStr(t *testing.T) {
e := PasteStr("s")
tt.Empty(t, e)
uc := toUC("s")
tt.Equal(t, "[s]", uc)
s1 := "abc\\\\cd/s@世界"
uc := ToUC(s1)
tt.Equal(t, "[a b c \\ \\ c d / s @ U4e16 U754c]", uc)
}
func TestKeyCode(t *testing.T) {