A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearHow to get &nbsp to behave properly using HTML Purifier? - page 1
User InfoPosts
How to get &nbsp to behave properly using HTML Purifier?#1
I am using HTML Purifier in my PHP project and am having trouble getting it to work properly with user input.

I am having users enter in HTML using a WYSIWYG editor (TinyMCE), but whenever a user enters in the HTML entity   (non-breaking space) it gets saved into the database as this weird foreign character (Â).

However, the thing is, when I edit the saved entry using the WYSIWYG editor it gets displayed properly as  . It also functions properly when displayed, only that in the source code it appears as a real space, but not the non-breaking space character.

Also, in the MySQL database it displays as the weird foreign character.

I read the doc about Unicode and HTML Purifier and changed my database and web page encoding to be UTF-8, but I am still having problems with the non-breaking space character not being mangled. The other HTML entities, such as &lt; and &gt;, get saved as < and >, but why not &nbsp;?

posted date: 2008-12-18 13:23:00


Re: How to get &nbsp to behave properly using HTML Purifier?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-18 13:23:01


Re: How to get &nbsp to behave properly using HTML Purifier?#3
Wrap entities and HTML in code tags (look at my edit!) to prevent them from being interpreted as actual HTML.

posted date: 2008-12-18 13:30:00


Re: How to get &nbsp to behave properly using HTML Purifier?#4
The non-breaking space isn't being saved in your database as one weird foreign character, it's being saved as two characters. The Unicode non-breaking space character is encoded in UTF-8 as 0xC2 0xA0, which in ISO-8859-1 looks like " " (i.e. a weird foreign character followed by a non-breaking space).You're probably forgetting to do SET NAMES 'utf8' on your database connection, which causes PHP to send its data to MySQL as ISO-8859-1 (the default).Have a look at "UTF-8 all the way through…" to see how to properly set up UTF-8 when using PHP and MySQL.

posted date: 2008-12-18 14:13:00


Re: How to get &nbsp to behave properly using HTML Purifier?#5
It may also help you to know that &#160; is an alternate for &nbsp; which you will likely require if you ever output any human readable XML ;)

posted date: 2008-12-19 04:42:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.