From: <ope...@li...> - 2005-12-21 14:23:07
|
Update of /cvsroot/openca/openca-0.9/src/common/lib/javascript/el_GR In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8548/openca-0.9/src/common/lib/javascript/el_GR Modified Files: Tag: openca_0_9_2 signForm.vbs Log Message: fixed utf8 problem if signing with VBScript in IE Author of changes: michaelbell Index: signForm.vbs =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/common/lib/javascript/el_GR/Attic/signForm.vbs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** signForm.vbs 13 Oct 2005 14:44:50 -0000 1.1.2.1 --- signForm.vbs 21 Dec 2005 14:22:30 -0000 1.1.2.2 *************** *** 1,3 **** --- 1,46 ---- <!--' + + Function UTF16toUTF8ByteArray(strUTF16) + Dim i, UTF16, UTF8 + Dim aryTmp, strTmp + For i=1 To Len(strUTF16) + UTF16 = AscW(Mid(strUTF16, i, 1)) + aryTmp = ToUTF8(UTF16) + For Each strTmp In aryTmp + If Len(Hex(strTmp)) > 1 Then + UTF8 = UTF8 & Hex(strTmp) + Else + UTF8 = UTF8 & "0" & Hex(strTmp) + End If + Next + Next + + Dim CapicomUtil + Set CapicomUtil = CreateObject("CAPICOM.Utilities") + UTF16toUTF8ByteArray = CapicomUtil.HexToBinary(UTF8) + End Function + + Function ToUTF8(ByVal UTF16) + ' Convert a 16bit UTF-16BE to 2 or 3 UTF-8 bytes + Dim BArray() + If UTF16 < &H80 Then + ReDim BArray(0) ' one byte UTF-8 + BArray(0) = UTF16 ' Use number as Is + Elseif UTF16 < &H800 Then + ReDim BArray(1) ' two byte UTF-8 + BArray(1) = &H80 + (UTF16 And &H3F) ' Least Significant 6 bits + UTF16 = UTF16 \ &H40 ' Shift UTF16 number right 6 bits + BArray(0) = &HC0 + (UTF16 And &H1F) ' Use 5 remaining bits + Else + ReDim BArray(2) ' three byte UTF-8 + BArray(2) = &H80 + (UTF16 And &H3F) ' Least Significant 6 bits + UTF16 = UTF16 \ &H40 ' Shift UTF16 number right 6 bits + BArray(1) = &H80 + (UTF16 And &H3F) ' Use next 6 bits + UTF16 = UTF16 \ &H40 ' Shift UTF16 number right 6 bits again + BArray(0) = &HE0 + (UTF16 And &HF) ' Use 4 remaining bits + End If + ToUTF8 = BArray ' Return UTF-8 bytes in an Array + End Function + Function signFormIE(theForm, theWindow) Dim SignedData *************** *** 13,17 **** End If ! SignedData.Content = theForm.text.value ' we cannot use normally because MsgBox can only handle up to 1024 characters --- 56,60 ---- End If ! SignedData.Content = UTF16toUTF8ByteArray(theForm.text.value) ' we cannot use normally because MsgBox can only handle up to 1024 characters |