469,902 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

Byte string to Unicode & vice versa

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 ***
Apr 27 '06 #1
1 2287
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 ***
Apr 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

43 posts views Thread by Bill Cunningham | last post: by
2 posts views Thread by crater | last post: by
3 posts views Thread by Lau Lei Cheong | last post: by
9 posts views Thread by Pohihihi | last post: by
16 posts views Thread by Hugh Janus | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.