There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 boot bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware help please hijackthis hjt hjt log install internet internet explorer itunes javascript keyboard lan laptop log malware monitor network networking outlook outlook 2003 outlook express password php popups problem router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless youtube
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
htmlspecialchar and Japanese


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Zenoxio's Avatar
Computer Specs
Senior Member with 216 posts.
 
Join Date: Jul 2006
Location: Saratoga Springs, NY
Experience: Advanced
13-May-2008, 03:46 PM #1
htmlspecialchar and Japanese
I have a site where a user can enter data into a field, which is then stored into a database. I am using htmlspecialchar and addslashes to prevent XSS and SQL injection.

The problem is that if I enter Japanese characters, htmlspecialchar ends up doing something wrong to them. I think the chars are stored via Unicode, and it's taking the & and changing it into & which is then unrendering the Japanese when it is displayed on the webpage.

Any clues how I should go about this?
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
14-May-2008, 12:51 PM #2
Have you tried setting the charset parameter to htmlspecialchars()? It should be SJIS or EUCJP for Japanese: http://php.net/htmlspecialchars
Zenoxio's Avatar
Computer Specs
Senior Member with 216 posts.
 
Join Date: Jul 2006
Location: Saratoga Springs, NY
Experience: Advanced
14-May-2008, 12:57 PM #3
Is that okay to do if the data is primarily English, but may contain Japanese?
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
14-May-2008, 10:32 PM #4
It should be whatever character set the data is encoded with, I suppose you'd have to try it and see if it works for your data.
Zenoxio's Avatar
Computer Specs
Senior Member with 216 posts.
 
Join Date: Jul 2006
Location: Saratoga Springs, NY
Experience: Advanced
15-May-2008, 08:53 AM #5
How would I check what char set the data is? Do you mean the input box? That doesn't have a char set on it (that I specifically set).
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
15-May-2008, 06:28 PM #6
The character set is what the user enters in the input box. I am not really sure if setting it to Japanese in htmlspecialchars() will fix this problem, but it's worth trying.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:33 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.