FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Thorny string translation issue.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Thorny string translation issue. [message #180801 is a reply to message #180782] Tue, 19 March 2013 12:58 Go to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma:
Senior Member
On Mon, 18 Mar 2013 23:24:31 +0000, The Natural Philosopher wrote:
>
>
> The problem.
>
> I want the user to enter raw text and embedded HTML into a database. No
> trouble with getting it in, but when getting it out, it needs massaging
> for display..
>
> Now I cant find a function in the library that will skip html styles
> like <b>...</b> or <a...></a> code, and yet still tranlsatee e.g. '>' to
> '&gt;' etc etc.
>
> Anyone done this before?

Sorry to say, either it's HTML or it's not and bare anglebraces are
not HTML. There's no way to reliably tokenize only some angles without
serious context analysis, and even a reasonably complex regular
expression isn't going to be able to get EVERYTHING right. Your only
path that I see is to load a DTD and essentially pre-render the document
in memory to handle the real tags, convert everthing that's left to
entities, and then compare/build the two copies, taking the tags from
the raw file and the entities from the rendered-and-converted one. And
even that could screw things up at least differently from some other
means of rendering things, so results could vary.

--
Surely the 98% of DNA we share with monkeys must be enough to stop
people from sinking this low.
-- Frossie
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hot list for BA/QA- Load Runner, Software Tester, Business Analyst/ Project Coordinator & SAP Business Object Developer
Next Topic: split array and string from string (trust me it will make sense when you read)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 23:12:54 GMT 2024

Total time taken to generate the page: 0.11809 seconds