ut8 encoding issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
condorchou
Forum Newbie
Posts: 2
Joined: Wed Feb 11, 2009 10:24 pm

ut8 encoding issue

Post by condorchou »

I am writing user inputs into a xml file. This file is then read in using the DOMdocument object.

How do I encode the following string:

"Billy’s &"

Please be aware that this ' is different from ’

ut8_encode encodes the funny apostrophe but not the ampersand. htmlentities encodes the ampersand but not the funny apostrophe.

Can someone help?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: ut8 encoding issue

Post by requinix »

condorchou wrote:ut8_encode encodes the funny apostrophe but not the ampersand. htmlentities encodes the ampersand but not the funny apostrophe.
So... do both. htmlentities first, utf8_encoding second.
condorchou
Forum Newbie
Posts: 2
Joined: Wed Feb 11, 2009 10:24 pm

Re: ut8 encoding issue

Post by condorchou »

That was awesome. I thought I did this combination earlier today but the output was completely jibberish but trying it just now it worked. I still don't believe it. thanx.
Post Reply