Skip to content

mb_convert_encoding "\" (backslash) and "~" (tilde) convert failed to Shift_JIS #8281

Closed
@youkidearitai

Description

@youkidearitai

Description

Backslash(\) and tilde(~) is convert to Shift_JIS (SJIS) using mb_convrert_encoding, But converted word is wrong word. Please see below code and 3v4l https://3v4l.org/nSVPB. Reproduced only PHP 8.1.

The following code:

<?php
var_dump(mb_convert_encoding(mb_convert_encoding("\\", "SJIS", "UTF-8"), "UTF-8", "SJIS"));
var_dump(mb_convert_encoding(mb_convert_encoding("~", "SJIS", "UTF-8"), "UTF-8", "SJIS"));

Resulted in this output:

string(3) "\"
string(3) "〜"

But I expected this output instead:

string(1) "\"
string(1) "~"

PHP Version

PHP 8.1.4

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions