HTML entities

Alex Tweedly alex at tweedly.net
Mon May 29 21:23:16 EDT 2006


Sarah Reichelt wrote:

> Hi All,
>
> I have a field of data that I want to format into a web page. The data
> can contain symbols, most likely just the degree symbol but possibly
> others. If I get the htmltext of the field, it gives me the correct
> entity for the degree symbol: °
>
> However I don't want to use the htmltext, since I am building my own
> table display from the data. Is there a way to translate a symbol to
> it's html entity? I suppose I could just use a lookup table of the
> likely candidates and loop through them, replacing as necessary, but
> since Rev "knows" the entities, I was hoping there was a function that
> I haven't spotted, to get them directly.
>
You could cut/paste the list from the rev docs :-)


I'm not suggesting this directly, but you could do something based on ...

repeat with i = 1 to the number of chars in fld "Field"
  if "&" is in the htmltext of char i of fld "Field" then
    put char i of fld "Field" && the htmltext of char i of fld "Field" & 
cr after msg
  end if
end repeat


(or fill a field with numtochar(i) for all i, and build a table that way)
put empty into fld "Field"
repeat with i =1  to 255
   put numtochar(i) after fld "Field"
end repeat
repeat with i = 1 to the number of chars in fld "Field"
  if "&" is in the htmltext of char i of fld "Field" then
    put  i && the htmltext of char i of fld "Field" & cr after msg
  end if
end repeat

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.7.3/350 - Release Date: 28/05/2006




More information about the Use-livecode mailing list