Foxtable(狐表)用户栏目专家坐堂 → Ukey是不是只能写入字母和数字,汉字不能写入呢?


  共有2309人关注过本帖树形打印复制链接

主题:Ukey是不是只能写入字母和数字,汉字不能写入呢?

帅哥哟,离线,有人找我吗?
lhpc120
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:633 积分:6320 威望:0 精华:0 注册:2011/5/8 13:21:00
Ukey是不是只能写入字母和数字,汉字不能写入呢?  发帖心情 Post By:2015/6/14 4:15:00 [只看该作者]

RT:

If UKey.Start() Then
    Dim
Val As String = "联想Lenovo"
    If
UKey.LenStrA(Val) > 50 Then
       
MessageBox.Show("用户名长度不能超过50个字节!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        If
UKey.WriteStr(0,val,"46DFA0D7","C292C1DB") = True
           
MessageBox.Show("成功写入数据!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
End If

采用官方的例子!也是写入失败!

首先确认,读写密码正确。    测试过N次,只要写入字母和数字都可以,就是不能写入汉字!

请官方给出解答!

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/14 10:21:00 [只看该作者]

 嗯嗯,是的,中文字符还得进行转码存储,取出还得还原,如

 

 

Dim str As String = "联想Aabc"
Dim bs() As Byte = Encoding.Unicode.GetBytes(str)
Dim nstr As String = ""
For Each b As Byte In bs
    nstr &= b.ToString("x") & ","
Next
nstr = nstr.Trim(",")
output.show(nstr)

 

'----------------转回去

 

Dim strAry() As String = nstr.Split(",")
Dim bys(strAry.Length-1) As Byte
For i As Integer = 0 To strAry.Length - 1
    Bys(i) = Byte.Parse(strAry(i), System.Globalization.NumberStyles.HexNumber)
Next
Dim bstr As String = Encoding.Unicode.GetString(bys)
output.show(bstr)


 回到顶部