代碼: 選擇全部
<%
Response.Write ConvUnicode(FromUnicode("強力Power鎯頭Hammer"))
' FromUnicode
Private Function FromUnicode(strData)
Dim objStm
Set objStm = Server.CreateObject("ADODB.Stream")
With objStm
.Charset = "Big5"
.Type = 2
.Open
.WriteText strData
.Position = 0
.Charset = "Unicode"
.Type = 1
FromUnicode = MidB(.Read, 1)
End With
End Function
' Unicode
Public Function ConvUnicode(ByVal strData)
Dim rs, stm, bytAry, intLen
If Len(strData & "") > 0 Then
strData = MidB(strData, 1)
intLen = LenB(strData)
Set rs = Server.CreateObject("ADODB.Recordset")
Set stm = Server.CreateObject("ADODB.Stream")
With rs
.Fields.Append "X", 205, intLen
.Open
.AddNew
rs(0).AppendChunk strData & ChrB(0)
.Update
bytAry = rs(0).GetChunk(intLen)
End With
With stm
.Type = 1
.Open
.Write bytAry
.Position = 0
.Type = 2
.Charset = "Big5"
ConvUnicode = .ReadText
End With
End If
On Error Resume Next
stm.Close
Set stm = Nothing
rs.Close
Set rs = Nothing
End Function
%>