/    Sign up×
Community /Pin to ProfileBookmark

My utf-form has problem……….

My simple utf-form is as follows:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>A UTF-8 form</title>
</head>
<body>
<form name=”utf-form” method=”post” action=”temp2.php”>
<INPUT TYPE=”text” NAME=”textbox1″ value=”<?php echo trim(htmlentities(stripslashes($_POST[‘textbox1’]))); ?>”>
</form>
</body>
</html>

After I submitted with something like “&#22825;&#20027;&#25945;”, this form returned with the textbox1 value as garbage characters, which is incorrect.

If I just use $_POST[‘textbox1’] without stripslashes() and htmlentities() and trim() then this form returned with the textbox1 value as “&#22825;&#20027;&#25945;”, which is correct.

I need to use stripslashes() and htmlentities() and trim() so how shall I overcome the limit or solve this utf-8 PHP problem please?

Thanks for any replies in advance!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@caanoeeAug 30.2008 — Why do you have to use htmlentities()? php and mySql works good with chinese and it is not necessary to convert it to somethink else.
×

Success!

Help @dc2698 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...