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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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-2022 The PHP Group
All rights reserved.
Last updated: Sat May 28 17:05:46 2022 UTC