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

  • SEARCH
  • Home
  • 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 6054023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:06:21+00:00 2026-05-23T08:06:21+00:00

we have a web application where we allow users to enter their own html

  • 0

we have a web application where we allow users to enter their own html in a text area. We save that data to our database.

When we load the html data into the text area, of course, we use htmlentities() before throwing the html data into the textarea. Otherwise users could save inside the textarea and our application would break when loading that into the textarea.

this works great, except when entering Chinese characters (and probably other languages such as Arabic, Japanese).

The htmlentities() makes the chinese text unusable like this: �¨�³�¼�§ï
When I remove the htmlentities() before loading the entered html into the text area, Chinese characters show up just fine, but then we have the problem of HTML interfering with our textarea, especially when a users enters inside the text area.

I hope that makes sense.

Does anyone know how we can safely and correctly allow languages such as Chinese, Japanese, … to be used inside our text area, while still being safe for loading any html inside our text area?

  • 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-23T08:06:22+00:00Added an answer on May 23, 2026 at 8:06 am

    Have you tried using htmlspecialchars?

    I currently use that in production and it’s fine.

    $foo = "我的名字叫萨沙"
    echo '<textarea>' . htmlspecialchars($foo) . '</textarea>';
    

    Alternately,

    $str = “&#20320;&#22909;”;
    echo mb_convert_encoding($str, ‘UTF-8′, ‘HTML-ENTITIES’);
    

    As found on http://www.techiecorner.com/129/php-how-to-convert-iso-character-htmlentities-to-utf-8/

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

Sidebar

Related Questions

In my web application I have created a form that will allow users to
I have an ASP.NET web application that has a fileupload control to allow users
I have a ASP.NET 3.5 web application and I would like to allow users
Let say, I have a web application that allows users to upload images and
We have created a web application, using ASP.NET, that allows users to upload documents
I have a web application that should behave differently for internal users than external
I have a web application where I would like to allow end users to
I have a system which allows users to enter HTML-reserved characters into a text
I have a web application that registered users use. These users have good email
I am currently designing a web application that will allow users to schedule tasks

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.