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 #180795 is a reply to message #180786] Tue, 19 March 2013 09:33 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 19/03/13 00:26, Christoph Becker wrote:
> The Natural Philosopher wrote:
>
>> 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.
>
> You can strip the tags with strip_tags() (note the $allowable_tags
> parameter) and later escape the HTML special characters with
> htmlspecialchars() (note the $encoding parameter, which may be necessary
> to prevent UTF-7 injection attacks). Simplified:
how do I put the tags I want back though.


Specifically consider the example

<b> <= </b>

where I want to display a bold 'arrow'

strip tags will just remove the tags I want.

But htmlspecialchars simply turns all tags into (displayed ) raw html.


>
>>>> $str='alpha <b>beta < gamma</b> delta';
>>>> htmlspecialchars(strip_tags($str));
> 'alpha beta &lt; gamma delta'
>

yes, but that's not the output I want.




--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
[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: Sat Nov 30 21:13:46 GMT 2024

Total time taken to generate the page: 0.03813 seconds