Conversion of hex pairs to chars...best way?
Richard Gaskin
ambassador at fourthworld.com
Thu May 22 16:20:01 EDT 2003
T. R. Ponn wrote:
> Here's something I've done MANY times with HC over the years and I'm
> hoping there's a less time consuming way to accomplish it with Rev:
>
> I have the need to convert mass quantities of lines of data in this form:
>
> "5265766F6C7574696F6E", as an example. They are pairs (base16) of:
>
> "82_101_118_111_108_117_116_105_111_110", in base10 (underscores added
> here for clarification). And they become:
>
> "Revolution" in ASCII chars.
>
> Now what I've *been* doing in Rev is something akin to:
>
> put empty into whatEverOut
> put "5265766F6C7574696F6E" into whatEver
> repeat with i=1 to the number of chars of whatEver
> put numToChar(baseConvert((char ((i*2)-1) to (i*2) of
> whatEver),16,10)) after whatEverOut
> end repeat
> put whatEverOut
>
> Is this a good way to do this, or is there something that can be done
> with a "repeat for each" form? This ( similar) is used soooooo much in
> my app that it's bound to make a significant difference. Oh...and
> occasionally I have to do this routine "in reverse".
Would using base64encode and base64decode functions provide you with a
similarly useful result?
--
Richard Gaskin
Fourth World Media Corporation
Developer of WebMerge 2.2: Publish any database on any site
___________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
Tel: 323-225-3717 AIM: FourthWorldInc
More information about the use-livecode
mailing list