Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-tfel.122.mcz==================== Summary ====================
Name: Collections-tfel.122
Author: tfel
Time: 28 August 2009, 9:17:27 am
UUID: 628fd0f2-dabf-403b-a887-e1cd7d5a4055
Ancestors: Collections-ar.121
For the Method asHtml we have HtmlEntities as class-side Dictionary. I propose to use it for asUnHtml as well and fail silently if we couldn't find a match instead of throwing an Error saying "please add the missing entity to this method"
=============== Diff against Collections-ar.121 ===============
Item was added:
Item was changed:
----- Method: String>>asUnHtml (in category 'converting') -----
asUnHtml
"Strip out all Html stuff (commands in angle brackets <>) and convert
the characters &<> back to their real value. Leave actual cr and tab as
they were in text."
+ | in out char rest |
- | in out char rest did |
in := ReadStream on: self.
out := WriteStream on: (String new: self size).
[in atEnd] whileFalse:
[in peek = $<
ifTrue: [in unCommand] "Absorb <...><...>"
ifFalse: [(char := in next) = $&
ifTrue: [rest := in upTo: $;.
+ out nextPut: (HtmlEntities
+ at: rest
+ ifAbsent: [Character space])]
- did := out position.
- rest = 'lt' ifTrue: [out nextPut: $<].
- rest = 'gt' ifTrue: [out nextPut: $>].
- rest = 'amp' ifTrue: [out nextPut: $&].
- rest = 'deg' ifTrue: [out nextPut: $°].
- rest = 'quot' ifTrue: [out nextPut: $"].
- rest = 'nbsp' ifTrue: [out nextPut: Character space].
- did = out position ifTrue: [
- self error: 'unknown encoded HTML char'.
- "Please add it to this method"]]
ifFalse: [out nextPut: char]].
].
^ out contents!