0

I am making a website where one fills out a form and it creates a PDF. The user will be able to put in diacritic and special characters. The way I am sending the characters to the PHP, those characters will come into the PHP as HTML coded characters i.e. à. I need to change this to whatever it is PHP will read so when I put it through the PDF maker we have it has the diacritic character and not the HTML code for it.

I wrote a test to try this out but I haven't been able to figure it out. If I have to I will end up writing an array for every possible character they can use and translate the incoming string but I am trying to find an easier solution.

Here is the code of my test:

$title = "Test of Title for use With This Project and it should also wrap because it is sò long!  Acutally it is even longer than previously expected!";
$ti = htmlspecialchars_decode($title);

I have been attempting to use the htmlspecialchars_decode() to convert it but it still comes out as &ograve and not ò. Is there an easy way to do this?

1
  • I used your exact code and it works like that for me... Commented Jan 5, 2012 at 16:20

2 Answers 2

1

See the documentation which tells you it won't touch most of the characters you care about and to use html_entity_decode instead.

Sign up to request clarification or add additional context in comments.

Comments

0

Use the html_entity_decode function instead of htmlspecialchars_decode (which only decodes entities such as &, ", < and > = special HTML chars, not all entities).

2 Comments

Thanks for the help guys. That is the right thing to do. Also to be specific for anyone else that sees this, you also need to include the full parameters of the function html_entity_decode(): $ti = html_entity_decode($title, ENT_QUOTES, "UTF-8"); Just thought I would add that side note. Thanks again for the help.
@SerenadeX: you can also upvote the (accepted) answer. To do so: click on the ^ icon to the left of the answer. (You can upvote as many answers as you think are 'good' -- you can accept only one answer though.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.