mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-36245 add tests for the buggy utf-8 to utf-8 conversion
This commit is contained in:
parent
e9a3070676
commit
04463c0ea6
1 changed files with 6 additions and 0 deletions
|
@ -62,29 +62,35 @@ class core_textlib_testcase extends advanced_testcase {
|
||||||
$this->assertSame(textlib::convert($iso2, 'iso-8859-2', 'win-1250'), $win);
|
$this->assertSame(textlib::convert($iso2, 'iso-8859-2', 'win-1250'), $win);
|
||||||
$this->assertSame(textlib::convert($iso2, 'iso-8859-2', 'iso-8859-2'), $iso2);
|
$this->assertSame(textlib::convert($iso2, 'iso-8859-2', 'iso-8859-2'), $iso2);
|
||||||
$this->assertSame(textlib::convert($win, 'win-1250', 'cp1250'), $win);
|
$this->assertSame(textlib::convert($win, 'win-1250', 'cp1250'), $win);
|
||||||
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
|
||||||
|
|
||||||
|
|
||||||
$utf8 = '言語設定';
|
$utf8 = '言語設定';
|
||||||
$str = pack("H*", "b8c0b8ecc0dfc4ea"); //EUC-JP
|
$str = pack("H*", "b8c0b8ecc0dfc4ea"); //EUC-JP
|
||||||
$this->assertSame(textlib::convert($utf8, 'utf-8', 'EUC-JP'), $str);
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'EUC-JP'), $str);
|
||||||
$this->assertSame(textlib::convert($str, 'EUC-JP', 'utf-8'), $utf8);
|
$this->assertSame(textlib::convert($str, 'EUC-JP', 'utf-8'), $utf8);
|
||||||
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
|
||||||
|
|
||||||
$str = pack("H*", "1b24423840386c405f446a1b2842"); //ISO-2022-JP
|
$str = pack("H*", "1b24423840386c405f446a1b2842"); //ISO-2022-JP
|
||||||
$this->assertSame(textlib::convert($utf8, 'utf-8', 'ISO-2022-JP'), $str);
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'ISO-2022-JP'), $str);
|
||||||
$this->assertSame(textlib::convert($str, 'ISO-2022-JP', 'utf-8'), $utf8);
|
$this->assertSame(textlib::convert($str, 'ISO-2022-JP', 'utf-8'), $utf8);
|
||||||
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
|
||||||
|
|
||||||
$str = pack("H*", "8cbe8cea90dd92e8"); //SHIFT-JIS
|
$str = pack("H*", "8cbe8cea90dd92e8"); //SHIFT-JIS
|
||||||
$this->assertSame(textlib::convert($utf8, 'utf-8', 'SHIFT-JIS'), $str);
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'SHIFT-JIS'), $str);
|
||||||
$this->assertSame(textlib::convert($str, 'SHIFT-JIS', 'utf-8'), $utf8);
|
$this->assertSame(textlib::convert($str, 'SHIFT-JIS', 'utf-8'), $utf8);
|
||||||
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
|
||||||
|
|
||||||
$utf8 = '简体中文';
|
$utf8 = '简体中文';
|
||||||
$str = pack("H*", "bcf2cce5d6d0cec4"); //GB2312
|
$str = pack("H*", "bcf2cce5d6d0cec4"); //GB2312
|
||||||
$this->assertSame(textlib::convert($utf8, 'utf-8', 'GB2312'), $str);
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'GB2312'), $str);
|
||||||
$this->assertSame(textlib::convert($str, 'GB2312', 'utf-8'), $utf8);
|
$this->assertSame(textlib::convert($str, 'GB2312', 'utf-8'), $utf8);
|
||||||
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
|
||||||
|
|
||||||
$str = pack("H*", "bcf2cce5d6d0cec4"); //GB18030
|
$str = pack("H*", "bcf2cce5d6d0cec4"); //GB18030
|
||||||
$this->assertSame(textlib::convert($utf8, 'utf-8', 'GB18030'), $str);
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'GB18030'), $str);
|
||||||
$this->assertSame(textlib::convert($str, 'GB18030', 'utf-8'), $utf8);
|
$this->assertSame(textlib::convert($str, 'GB18030', 'utf-8'), $utf8);
|
||||||
|
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue