Htmlspecialchars ($value) causes Chinese to be lost

Source: Internet
Author: User
Tags vc9
I downloaded a set of source code, using GB2312 page encoding.
Which calls the CKEditor and the background management of the Chinese processing is the use of Htmlspecialchars ($value) to filter out the HTML dangerous characters.
The problem is not sure how, after the Htmlspecialchars ($value) processing the Chinese is empty?
Later read the data said to call this:
Htmlspecialchars ($value, Ent_noquotes, "gb2312")


The problem is: I want to change, not to change a lot, and again, like CKEditor developers don't know the existence of this problem?
Urgent to find a simple solution, it is best not to change the source, there is a global setting or environment settings and so on, please help, thank you!


Reply to discussion (solution)

There is an encoding setting in php.ini, default_charset= "gb2312" trial

Tested, didn't find the problem you said

Besides, Htmlspecialchars is converting special characters to HTML entities, rather than filtering out HTML dangerous characters as you say

This function turns special characters into HTML string format (&....;)
This has nothing to do with Chinese, unless you pass in the time is garbled and so on. Let's check the content you passed in.

My machine is XP +EASYPHP5.4.0RC4
Run

 
  
"; echo" after processing: ". Htmlspecialchars ($STR);? >


Returns a true null value.
No other treatment has been made.


Easyphp5.4.0rc4
is PHP version 5.4 stupid?
It's not that extravagant, I'm still using php5.3.6.

If it's php5.4, please notify the PHP bug website of the error


The test discovery is correct and the return value is not a null value
My machine is XP +EASYPHP5.4.0RC4
Run
HTML Code

$STR = "111 Chinesecharacters ...";
echo "is output as. $str
";
echo "After processing:". Htmlspecialchars ($STR);
?>




Returns a true null value.
No other treatment has been made.

I saw that the integration environment is like this:

    PHP 5.4.0RC4 VC9    Apache 2.2.21 VC9    MySQL 5.5.19    PhpMyAdmin 3.4.9 Xdebug 2.1.2    

is a version of the issue. PHP 5.4.0RC4 VC9 should still be beta. There are many bugs. .

Landlord change a easyphp 5.3/easyphp 5.2 estimate on the line.

Well. I changed the 5.3. Yes, sure. Thank you.

You stereotypes look, but

php5.4 also encountered this problem:

$content = htmlspecialchars ($_post[' content ');

Add to
, Ent_compat, ' GB2312 '
After that, there's no more convenient way to find out
$content = htmlspecialchars ($_post[' content '],ent_compat, ' GB2312 ');

php5.5 problems still have to be complete parameters

php5.5 problems still have to be complete parameters Yes, php5.5, I also encounter similar problems, in the test with DIRCMS, backstage a look, the title is empty, in code lookup, found to be the problem of this htmlspecialchars function, how to do?

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.