'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 19 September 2004 at 11:32:30 pm'! "Change Set: StringUnHtml Date: 19 September 2004 Author: Alexandre Bergel Complement to the post of Ram Krishnan. French and German accent are well handled. StringTest>>testUnHtml1 added"! !String methodsFor: 'converting' stamp: 'ab 9/19/2004 23:30'! 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 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: $;. 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 = 'eacute' ifTrue: [out nextPut: $]. rest = 'agrave' ifTrue: [out nextPut: $]. rest = 'auml' ifTrue: [out nextPut: $]. rest = 'iuml' ifTrue: [out nextPut: $]. rest = 'acirc' ifTrue: [out nextPut: $]. rest = 'icirc' ifTrue: [out nextPut: $]. rest = 'ocirc' ifTrue: [out nextPut: $]. rest = 'ecirc' ifTrue: [out nextPut: $]. rest = 'egrave' ifTrue: [out nextPut: $]. rest = 'ccedil' ifTrue: [out nextPut: $]. rest = 'euml' ifTrue: [out nextPut: $]. rest = 'ouml' ifTrue: [out nextPut: $]. did = out position ifTrue: [ self error: 'unknown encoded HTML char'. "Please add it to this method"]] ifFalse: [out nextPut: char]]. ]. ^ out contents! ! !StringTest methodsFor: 'unHtml' stamp: 'ab 9/19/2004 23:29'! testUnHtml1 "self debug: #testUnHtml1" self assert: 'Test' asUnHtml = 'Test'. self assert: '
Test' asUnHtml = 'Test'. self assert: '
éèàäïâîôêèçöë