Velocity Reviews > hex to string

# hex to string

Net Mongrel
Guest
Posts: n/a

 07-23-2004
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
Guest
Posts: n/a

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

Stan Scott
New York City

"Net Mongrel" <(E-Mail Removed)> wrote in message
news:9TZLc.5980\$(E-Mail Removed)...
> 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
Guest
Posts: n/a

 07-23-2004
Stan Scott wrote:
> "Net Mongrel" <(E-Mail Removed)> wrote in message
> news:9TZLc.5980\$(E-Mail Removed)...
>> 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