472,143 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

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)))
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))
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 2378
I did the improvement:

Function getString(StringBin)

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

End Function

Function getByte(ByteBin)

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

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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.