Home All Groups Group Topic Archive Search About

Byte string to Unicode & vice versa



Author
27 Apr 2006 10:09 AM
Eugene Anthony
Private Function BStr2UStr(BStr)
'Byte string to Unicode string conversion
   Dim lngLoop
   BStr2UStr = ""
   For lngLoop = 1 to LenB(BStr)
    BStr2UStr = BStr2UStr & Chr(AscB(MidB(BStr,lngLoop,1)))
   Next
End Function

Private Function UStr2Bstr(UStr)
'Unicode string to Byte string conversion
   Dim lngLoop
   Dim strChar
   UStr2Bstr = ""
   For lngLoop = 1 to Len(UStr)
    strChar = Mid(UStr, lngLoop, 1)
    UStr2Bstr = UStr2Bstr & ChrB(AscB(strChar))
   Next
End Function

Is there an alternative method (easy & efficient) way of writing the
code for converting Byte string to Unicode & vice versa for the code
shown above?

Your help is kindly appreciated.

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***

Author
28 Apr 2006 9:57 AM
Eugene Anthony
I did the improvement:

Function getString(StringBin)

  getString =""
  For intCount = 1 to LenB(StringBin)
    getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
  Next

End Function

Function getByte(ByteBin)

  getByte =""
  For intCount = 1 to LenB(ByteBin)
    getByte = getByte & chrB(AscB(Mid(StringBin,intCount,1)))
  Next

End Function

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***

AddThis Social Bookmark Button