Function to replace characters with HTML character references ( < > )? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- alpine · 2024-04-30 13:05 I'm looking into the fpc packages for such a function but I can't find one. There should be one somewhere (fcl-web), with such a developed infrastructure... ---------------------------------------------------------------------- Josh · 2024-04-30 13:20 unit httpprotocol has a httpdecode and httpdecode function any use ? ---------------------------------------------------------------------- alpine · 2024-04-30 13:25 Quote from: Josh on April 30, 2024, 03:20:45 pmunit httpprotocol has a httpdecode and httpdecode function any use ? Thanks for reply! Found these but they are for URL encoding (+%xxx+). ---------------------------------------------------------------------- dsiders · 2024-04-30 18:11 Quote from: alpine on April 30, 2024, 03:05:48 pmI'm looking into the fpc packages for such a function but I can't find one. There should be one somewhere (fcl-web), with such a developed infrastructure... EscapeHTML() and  UnescapeHTML() routines are located in htmlelements.pp in the fcl-xml package. ---------------------------------------------------------------------- Kays · 2024-04-30 21:52 EscapeHTML can only handle ampersand, less than, greater than, inch sign, and dumb apostrophe, yet there are 1926 character entities. I don’t think Alpine would’ve asked his question if all he needed was escaping the special meaning characters ampersand and less than sign. He could’ve accomplished that on his own. ---------------------------------------------------------------------- dsiders · 2024-04-30 22:29 Quote from: Kays on April 30, 2024, 11:52:08 pmEscapeHTML can only handle ampersand, less than, greater than, inch sign, and dumb apostrophe, yet there are 1926 character entities. I don’t think Alpine would’ve asked his question if all he needed was escaping the special meaning characters ampersand and less than sign. He could’ve accomplished that on his own. It's hard to answer a question that was not asked... ---------------------------------------------------------------------- delphius · 2024-04-30 23:05 Take a look at https://www.benibela.de/documentation/bbutils/bbutils.h tml#strDecodeHTMLEntities Its missing fpc functions But we need to solve the opposite problem. Benny's methods are quite complex and close to black magic, but here I laid out a principle that can be easily reversed https://github.com/delphius/htmlparser https://github.com/delphius/htmlparser/blob/d73faa9a5785514726a946b8af 09dbee256d0efa/HTML2TextRenderer.pas#L267 There are 2231 entities ))) https://github.com/delphius/htmlparser/blob/main/entities.inc P.S. It's the only place I know that is close to what you are looking for https://gitlab.com/freepascal.org/lazarus/lazarus/- /blob/main/components/lazutils/html2textrender.pas#L293 But there's only 3! entities in the function ---------------------------------------------------------------------- alpine · 2024-04-30 23:10 @Kays Wow, I didn't knew they are so many. I've expected something in the hundreds. @dsiders Thank you for pointing me to fcl-xml. Meanwhile, I really wrote a one-liner stub which happens to be just like the one in the htmlelements.pp. Just hoped for something more comprehensive. ---------------------------------------------------------------------- Roland57 · 2024-05-01 19:23 A link that might be useful: https://html.spec.whatwg.org/multipage/named-characters.html