# hex to string

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

1. ### Net MongrelGuest

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

Net Mongrel, Jul 23, 2004

2. ### Stan ScottGuest

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

3. ### Net MongrelGuest

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