Byte string to Unicode & vice versa

Discussion in 'ASP General' started by Eugene Anthony, Apr 27, 2006.

  1. 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 ***
     
    Eugene Anthony, Apr 27, 2006
    #1
    1. Advertising

  2. 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 ***
     
    Eugene Anthony, Apr 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. carmen
    Replies:
    4
    Views:
    30,809
    ersecchio
    Jan 12, 2010
  2. Flyingaway
    Replies:
    6
    Views:
    22,847
    Jack Klein
    Feb 19, 2005
  3. Byron
    Replies:
    6
    Views:
    518
    Byron
    Sep 16, 2004
  4. thinktwice
    Replies:
    4
    Views:
    940
    =?iso-8859-1?q?Kirit_S=E6lensminde?=
    Sep 7, 2006
  5. chen li
    Replies:
    3
    Views:
    140
    Daniel Martin
    Jul 13, 2007
Loading...

Share This Page