php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46794 addslashes() generate mojibake for single byte(Shift_JIS)
Submitted: 2008-12-08 06:29 UTC Modified: 2008-12-08 08:36 UTC
From: sohel62 at yahoo dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.2.7 OS: Win 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 - 10 = ?
Subscribe to this entry?

 
 [2008-12-08 06:29 UTC] sohel62 at yahoo dot com
Description:
------------
When I tried to use addslashes() function before store data into the database for the following string and the string was encoded as Shift_JIS that was broken.

紹介予定派遣

Except that string there are some other characters also show mojibake too.

Best regard
Taslim Sohel

Reproduce code:
---------------
echo addslashes('紹介予定派遣');

Expected result:
----------------
紹介予\定派遣

Actual result:
--------------
紹介予定派遣

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-08 08:36 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

addslashes only deals with bytes, and has no notion about character sets. Therefore it doesn't know it deals with Shift_JIS and can not escape those with addslashes properly. This is something that will be addressed in PHP 6.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 10:01:29 2024 UTC