×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Japanese Character

Japanese Character

Japanese Character

(OP)
I have the following code in a form submission and it jumbles my Japanese text -

CODE --> php

$name = ucfirst(strtolower(strip_tags($_REQUEST["name"]))); 

When I replaced it with the following my Japanese text is ok -

CODE --> php

$name=$_REQUEST['name']; 

The following field also gives me some jumbled text SOMETIMES -

CODE --> php

$content = strip_tags($_REQUEST['content']); 

What is the best way to handle the Japanese text and strip out anything that is not needed (not really sure what that might be) but keep the text from being jumbled.
I guess it has something to do with Japanese characters being 2 bytes per character.

Thanks

RE: Japanese Character

Hi

I would try to use Multibyte String Functions where available :

CODE --> PHP

// instead of
$name = ucfirst(strtolower($_REQUEST["name"])); 
// try
$name = mb_strtoupper(mb_substr($_REQUEST["name"], 0, 1)) . mb_strtolower(mb_substr($_REQUEST["name"], 1)), 

strip_tags() is a harder problem, but if you not need its 2nd parameter anyway, then you could try to use preg_replace() with u modifier :

CODE --> PHP

// instead of
$content = strip_tags($_REQUEST['content']);
// try
$content = preg_replace('/<.*?>/u', '', $_REQUEST['content']); 

Feherke.
feherke.github.io

RE: Japanese Character

(OP)
Thanks for your help.
What are the two examples I posted actually doing to the stored values and is there anything wrong with using just -

CODE --> php

$name=$_REQUEST['name']; 
$name=$_REQUEST['content']; 

Thanks

RE: Japanese Character

(OP)
Can anyone explain?
Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close