'From Squeak3.1alpha of 5 February 2001 [latest update: #3841] on 15 March 2001 at 10:50:33 am'! "Change Set: HTMLspecialEntity-mdr Date: 25 February 2001 Author: Mike Rutenberg HTML allows you to insert specific character value by number, for example is a space. We can display values in range [9,255] (similar to HTML 3.2) This fix ensures that out of range refereneces, e.g. “ are replaced with suitable substitutes or with a space character, and do not cause a walkback "! !HtmlEntity class methodsFor: 'character entities' stamp: 'mdr 2/27/2001 10:22'! valueOfHtmlEntity: specialEntity "Return the character equivalent to the HTML entity." | value | (specialEntity beginsWith: '#') "Handle numeric entities" ifTrue: [ "NB: We can display only simple numeric special entities in the" "range [9..255] (HTML 3.2). HTML 4.01 allows the specification of 16 bit" "characters, so we do a little fiddling to handle a few special cases" value _ (specialEntity copyFrom: 2 to: specialEntity size) asNumber. "Replace rounded left & right double quotes (HTML 4.01) with simple double quote" (value = 8220 or: [value = 8221]) ifTrue: [ value _ $" asInteger ]. "Replace rounded left & right single quotes (HTML 4.01) with simple single quote" (value = 8216 or: [value = 8217]) ifTrue: [ value _ $' asInteger ]. "Replace with a space if outside the normal range (arbitrary choice)" (value < 9 or: [value > 255]) ifTrue: [ value _ 32 ]. ] ifFalse: [ "Otherwise this is most likely a named character entity" value _ ReverseCharacterEntities at: specialEntity ifAbsent: [^nil]. ]. ^Character value: value.! !