Tuesday, July 19, 2005

How to convert the Numeric Unicde to Real Unicode

Below is the VB code segment to convert the numeric unicode &#.....; to Real Unicode in KnownAs field of a table X:

Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim RS01 As New ADODB.Recordset
Dim ConnStr As String

'Set Conn = Server.CreateObject("ADODB.Connection")
ConnStr = "Provider=SQLOLEDB;Server=someserver;Database=somedb;Uid=someuser;Password=password;"
Conn.Open ConnStr

SSQL = "select * from userlistcsv_unicode2"
RS01.Open SSQL, Conn, adOpenDynamic, adLockPessimistic

Do While Not RS01.EOF
KAStr = RS01("KnownAs")
RS01("KnownAs") = UniConvert(KAStr)
RS01.Update
DoEvents
RS01.MoveNext
Loop
RS01.Close
Set RS01 = Nothing
End Sub
Function UniConvert(Str)
' 陈舵蛻
parts = Split(Str, ";")
xx = ""
For Each part In parts
pos = InStr(1, part, "#")
If pos > 0 Then
xx = xx & Left(part, pos - 2) & ChrW(CLng(Mid(part, pos + 1)))
Else
xx = xx & part
End If
Next
UniConvert = xx
End Function

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home