[squeak-dev] Today's price for "nastiest code seen' goes to...

tim Rowledge tim at rowledge.org
Fri Apr 3 22:59:24 UTC 2020


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; tim at rowledge.org; http://www.rowledge.org/tim
Never test for an error condition you don't know how to handle.




More information about the Squeak-dev mailing list