| @@ 722-741 (lines=20) @@ | ||
| 719 | /** |
|
| 720 | * @ticket 28786 |
|
| 721 | */ |
|
| 722 | function test_wp_json_encode_non_utf8() |
|
| 723 | { |
|
| 724 | if (! function_exists('mb_detect_order') ) { |
|
| 725 | $this->markTestSkipped('mbstring extension not available.'); |
|
| 726 | } |
|
| 727 | ||
| 728 | $old_charsets = $charsets = mb_detect_order(); |
|
| 729 | if (! in_array('EUC-JP', $charsets) ) { |
|
| 730 | $charsets[] = 'EUC-JP'; |
|
| 731 | mb_detect_order($charsets); |
|
| 732 | } |
|
| 733 | ||
| 734 | $eucjp = mb_convert_encoding('aあb', 'EUC-JP', 'UTF-8'); |
|
| 735 | $utf8 = mb_convert_encoding($eucjp, 'UTF-8', 'EUC-JP'); |
|
| 736 | ||
| 737 | $this->assertEquals('aあb', $utf8); |
|
| 738 | ||
| 739 | $this->assertEquals('"a\u3042b"', wp_json_encode($eucjp)); |
|
| 740 | ||
| 741 | mb_detect_order($old_charsets); |
|
| 742 | } |
|
| 743 | ||
| 744 | /** |
|
| @@ 747-766 (lines=20) @@ | ||
| 744 | /** |
|
| 745 | * @ticket 28786 |
|
| 746 | */ |
|
| 747 | function test_wp_json_encode_non_utf8_in_array() |
|
| 748 | { |
|
| 749 | if (! function_exists('mb_detect_order') ) { |
|
| 750 | $this->markTestSkipped('mbstring extension not available.'); |
|
| 751 | } |
|
| 752 | ||
| 753 | $old_charsets = $charsets = mb_detect_order(); |
|
| 754 | if (! in_array('EUC-JP', $charsets) ) { |
|
| 755 | $charsets[] = 'EUC-JP'; |
|
| 756 | mb_detect_order($charsets); |
|
| 757 | } |
|
| 758 | ||
| 759 | $eucjp = mb_convert_encoding('aあb', 'EUC-JP', 'UTF-8'); |
|
| 760 | $utf8 = mb_convert_encoding($eucjp, 'UTF-8', 'EUC-JP'); |
|
| 761 | ||
| 762 | $this->assertEquals('aあb', $utf8); |
|
| 763 | ||
| 764 | $this->assertEquals('["c","a\u3042b"]', wp_json_encode(array( 'c', $eucjp ))); |
|
| 765 | ||
| 766 | mb_detect_order($old_charsets); |
|
| 767 | } |
|
| 768 | ||
| 769 | /** |
|