'From Squeak3.4 of 1 March 2003 [latest update: #5170] on 23 March 2003 at 11:56:06 am'! !HtmlEntity class methodsFor: 'character entities' stamp: 'BLV 3/23/2003 11:55'! 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" "The standard requires us to interpret numeric entities as Unicode" "codepoints; so for 8-bit we should convert ISO-8859-1 to MacRoman." (specialEntity at: 2) asLowercase = $x ifTrue: [ value _ (specialEntity copyFrom: 3 to: specialEntity size) asNumberBase: 16. ] ifFalse: [ 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.! ! !Number class methodsFor: 'instance creation' stamp: 'BLV 3/23/2003 11:21'! readFromString: aString base: aBase "Create a number based on the contents of aString in base aBase" ^self readFrom: (ReadStream on: aString) base: aBase! ! !String methodsFor: 'converting' stamp: 'BLV 3/23/2003 11:20'! asNumberBase: aBase "Answer the Number created by interpreting the receiver as the string representation of a number in a given base." ^Number readFromString: self base: aBase ! !