Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8737

Re: Thorny string translation issue.

From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: Thorny string translation issue.
Date 2013-03-19 07:58 -0500
Organization A noiseless patient Spider
Message-ID <slrnkkgo79.m9f.hellsop@nibelheim.ninehells.com> (permalink)
References <ki87ne$s68$1@news.albasani.net>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Thorny string translation issue. The Natural Philosopher <tnp@invalid.invalid> - 2013-03-18 23:24 +0000
  Re: Thorny string translation issue. Christoph Becker <cmbecker69@gmx.de> - 2013-03-19 01:26 +0100
    Re: Thorny string translation issue. The Natural Philosopher <tnp@invalid.invalid> - 2013-03-19 09:33 +0000
      Re: Thorny string translation issue. BootNic <bootnic.bounce@gmail.com> - 2013-03-19 07:45 -0400
      Re: Thorny string translation issue. Christoph Becker <cmbecker69@gmx.de> - 2013-03-20 00:56 +0100
  Re: Thorny string translation issue. SwissCheese <swisscheese@cfl.rr.com> - 2013-03-18 20:40 -0400
    Re: Thorny string translation issue. The Natural Philosopher <tnp@invalid.invalid> - 2013-03-19 09:38 +0000
  Re: Thorny string translation issue. Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-19 09:01 -0400
  Re: Thorny string translation issue. "Peter H. Coffin" <hellsop@ninehells.com> - 2013-03-19 07:58 -0500

csiph-web