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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sohel62 at yahoo dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Fri Dec 27 19:01:28 2024 UTC