hex to string

Discussion in 'ASP General' started by Net Mongrel, Jul 23, 2004.

  1. Net Mongrel

    Net Mongrel Guest

    converting string to hex like so:

    for x = 1 to len(source)
    target = target & hex(ascw(mid(source,x,1)))
    next

    How to convert it back to a string?

    I got as far as:

    for x = 1 to len(source) step 2
    target = target & chr("&H" & mid(source,x,2))
    next

    but this fails with the pound sign (£ - £)

    --
    Net
     
    Net Mongrel, Jul 23, 2004
    #1
    1. Advertising

  2. Net Mongrel

    Stan Scott Guest

    Can't you just use the escape() and unescape() methods? These convert to
    hex and back.

    Stan Scott
    New York City

    "Net Mongrel" <> wrote in message
    news:9TZLc.5980$...
    > converting string to hex like so:
    >
    > for x = 1 to len(source)
    > target = target & hex(ascw(mid(source,x,1)))
    > next
    >
    > How to convert it back to a string?
    >
    > I got as far as:
    >
    > for x = 1 to len(source) step 2
    > target = target & chr("&H" & mid(source,x,2))
    > next
    >
    > but this fails with the pound sign (£ - &pound;)
    >
    > --
    > Net
    >
    >
     
    Stan Scott, Jul 23, 2004
    #2
    1. Advertising

  3. Net Mongrel

    Net Mongrel Guest

    Stan Scott wrote:
    > "Net Mongrel" <> wrote in message
    > news:9TZLc.5980$...
    >> converting string to hex like so:
    >>
    >> for x = 1 to len(source)
    >> target = target & hex(ascw(mid(source,x,1)))
    >> next
    >>
    >> How to convert it back to a string?
    >>
    >> I got as far as:
    >>
    >> for x = 1 to len(source) step 2
    >> target = target & chr("&H" & mid(source,x,2))
    >> next
    >>
    >> but this fails with the pound sign (£ - &pound;)
    >>

    > Can't you just use the escape() and unescape() methods? These
    > convert to hex and back.
    >


    Thanks Stan, that's javascript right? I did a little digging and played
    around with the calls. They don't really do what I had in mind.

    I do need to get the hex pairs for each character and then change them back.

    --
    Net
     
    Net Mongrel, Jul 23, 2004
    #3
    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. Replies:
    10
    Views:
    6,282
    Neredbojias
    Aug 19, 2005
  2. Bengt Richter
    Replies:
    6
    Views:
    489
    Juha Autero
    Aug 19, 2003
  3. jack
    Replies:
    4
    Views:
    596
  4. tim

    hex string to hex value

    tim, Nov 22, 2005, in forum: Python
    Replies:
    8
    Views:
    18,976
  5. tim
    Replies:
    2
    Views:
    1,586
    Dennis Lee Bieber
    Nov 23, 2005
Loading...

Share This Page