Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 219541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:51:17+00:00 2026-05-11T18:51:17+00:00

Using PHP against a UTF-8 compliant database. Here’s how input goes in. user types

  • 0

Using PHP against a UTF-8 compliant database. Here’s how input goes in.

  1. user types input into textarea
  2. textarea encoded with javascript escape()
  3. passed via HTTP post
  4. decoded with PHP rawurldecode()
  5. passed through HTMLPurifier with default settings
  6. escaped for MySQL and stored in database

And it comes out in the usual way and I run unescape() on page load. This is to allow people to, say, copy and paste directly from a word document and have the smart quotes show up.

But HTMLPurifier seems to be clobbering non-UTF-8 special characters, ones that escape() to a simple % expression, like Ö, which escapes to %D6, whereas smartquotes escape to %u2024 or something and go into the database that way. It takes out both the special character and the one immediately following.

I need to change something in this process. Perhaps I need to change multiple things.

What can I do to not get special characters clobbered?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:51:17+00:00Added an answer on May 11, 2026 at 6:51 pm
    1. textarea encoded with javascript escape()

    escape isn’t safe for non-ascii. Use escapeURIComponent

    1. passed via HTTP post

    I assume that you use XmlHttpRequest? If not, make sure that the page containing the form is served as utf-8.

    1. decoded with PHP rawurldecode()

    If you access the value through $_POST, you should not decode it, since that has already been done. Doing so will mess up data.

    1. escaped for MySQL and stored in database

    Make sure you don’t have magic quotes turned on. Make sure that the database stores tables as utf-8 (The encoding and the collation must be both utf-8). Make sure that the connection between php and MySql is utf-8 (Use set names utf8, if you don’t use PDO).

    Finally, make sure that the page is served as utf-8 when you output the string again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 117k
  • Answers 117k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer 0x201a is the Unicode "low single comma quotation mark" character.… May 11, 2026 at 10:47 pm
  • Editorial Team
    Editorial Team added an answer The developerforce portal is your best bet to get information… May 11, 2026 at 10:47 pm
  • Editorial Team
    Editorial Team added an answer Try this: <?php if (!empty($_REQUEST['audio_field'])) { $url = array( 'deezer'=>'http://www.deezer.com/s.php?s=__keywords__',… May 11, 2026 at 10:47 pm

Related Questions

Using PHP against a UTF-8 compliant database. Here's how input goes in. user types
I am attempting to POST against a vendor's server using PHP 5.2 with cURL.
I'm trying to implement a stateful web service in PHP using the SOAP extension.
I'm using jquery ajax to post updates back to my server. I'm concerned about
I'm having trouble running a complex query against our company LDAP server. I'm using

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.