Not from Squeak, thank goodness
---------------------------------------------------------------- decode: aString " Answer the decoded representation of aString which is an encoded series of bytes" |ret answer tmpstr decoded plain | plain := String new. ret := String new. 1 to: aString size do: [ :x | ((String new copyWith: (aString at: x)) = '-') ifFalse: [ plain := plain, (String new copyWith: (aString at: x)). ] ]. plain do: [ :x | ret := ret, (rctable keyAtValueEqual: (String new copyWith: x) ifAbsent: [ '' ] ) ]. answer := OrderedCollection new. tmpstr := String new. 1 to: ret size do: [ :x | tmpstr := tmpstr, (String new copyWith: (ret at: x)). (tmpstr size = 8) ifTrue: [ answer add: tmpstr. tmpstr := String new. ] ]. decoded := String new. answer do: [ :x | decoded := decoded, (String new copyWith: (Character value: (ctable keyAtValueEqual: x))) ]. ^decoded asByteArray tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Never test for an error condition you don't know how to handle. |
> On 2020-04-03, at 3:59 PM, tim Rowledge <[hidden email]> wrote: > > Not from Squeak, thank goodness Or maybe the best candidate is rctable := Dictionary new. [rctable add: (Association key: '00000' value: 'A'). rctable add: (Association key: '00001' value: 'B'). rctable add: (Association key: '00010' value: 'C'). rctable add: (Association key: '00011' value: 'D'). {snipped to avoid too much pain} rctable add: (Association key: '11110' value: '5'). rctable add: (Association key: '11111' value: '8'). ] value. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Fractured Idiom:- FELIX NAVIDAD - Our cat has a boat |
Can't you C the love tonight? ;o)
|
In reply to this post by timrowledge
I smell a FORTAN DATA statement hiding there. 04 April 2020 01:09 tim Rowledge <[hidden email]> wrote:
|
> On 2020-04-04, at 8:27 AM, Bruce O'Neel <[hidden email]> wrote: > > > > I smell a FORTAN DATA statement hiding there. Hmm, interesting thought, though I suspect Marcel is actually correct - it's part of a very lazy transcription of an implementation of the Blowfish algorithm, so likely the original was C. I really haven't seen anything that nasty in ages. I mean, "String new copyWith:" eek! tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Useful random insult:- If you give him a penny for his thoughts, you get change back. |
Free forum by Nabble | Edit this page |