Use the ElfData plugin. http://www.elfdata.com/plugin/technicalref/
MSRM.html#ReplaceAll
There is this class for multiple search and replace, called "MSR".
It's perfectly suited for that sort of thing. It does it fast, RAM
efficiently, and with a simple API, and it scales well to large data
sizes.
You'd do it like this:
module HTMLEntitiesConvert
dim private m as MSR
function DecodeHTMLEntities(s as string) as string
if m = nil then LoadMSR
return m.ReplaceAll( s )
end function
private function LoadMSR
dim s as string
dim f as ElfDataFields
m = new MSR
f = new ElfDataFields( kConversionData, endofline )
// kConversionData looks like this:
// & &
// > >
// etc etc
while f.MoveNext
s = f.Field
m.Add nthfield( s, " ", 1 ), nthfield( s, " ", 2 )
wend
end function
end module
Then to use it, is very simple!
dim s as string
s = "Dorris&co."
s = DecodeHTMLEntities( s )
msgbox s
My ElfData plugin can also optionally auto-convert numeric entities!
http://www.elfdata.com/plugin/technicalref/MSRP.html#XMLEntity
XMLEntities and HTML entities are the same thing, so it works just
fine on HTML and XML.
I'll bet you can't write a faster converter for multiple entities
than my MSR, in any language!
From: "Carlos M" <[EMAIL PROTECTED]>
Date: Fri, 21 Apr 2006 12:17:29 +0100
On Apr 21, 2006 7:14 AM, Guyren Howe wrote:
Surprised to find that there doesn't appear to be a built-in HTML
entities decoding function in REALbasic. Has anyone written one?
Fifteen minutes of googling and searching rbgarage
surprisingly has not turned up one.
Guyren,
Check the "HTMLField 2" class from http://www.domainsoftworx.com
It has a "ReplaceHTMLEntities" method that replace some entities.
I agree that RB should have a coding/decoding HTML entities by
default.
I'm going to fill a feature request and will let you know the report
id.
--
http://elfdata.com/plugin/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>