1--TEST-- 2Test mb_convert_encoding() function : basic functionality 3--EXTENSIONS-- 4mbstring 5--FILE-- 6<?php 7/* 8 * Test basic functionality of mb_convert_encoding() 9 */ 10 11echo "*** Testing mb_convert_encoding() : basic functionality ***\n"; 12 13//All strings are the same when displayed in their respective encodings 14$sjis_string = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=='); 15$jis_string = base64_decode('GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=='); 16$euc_jp_string = base64_decode('xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=='); 17$utf8_string = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); 18 19echo "\n-- Convert to JIS --\n"; 20echo "JIS encoded string in base64:\n"; 21var_dump(base64_encode($jis_string)); 22echo "Converted Strings:\n"; 23var_dump(base64_encode(mb_convert_encoding($sjis_string, 'JIS', 'SJIS'))); 24var_dump(base64_encode(mb_convert_encoding($euc_jp_string, 'JIS', 'EUC-JP'))); 25var_dump(base64_encode(mb_convert_encoding($utf8_string, 'JIS', 'UTF-8'))); 26 27echo "\n-- Convert to EUC-JP --\n"; 28echo "EUC-JP encoded string in base64:\n"; 29var_dump(base64_encode($euc_jp_string)); 30echo "Converted Strings:\n"; 31var_dump(base64_encode(mb_convert_encoding($sjis_string, 'EUC-JP', 'SJIS'))); 32var_dump(base64_encode(mb_convert_encoding($jis_string, 'EUC-JP', 'JIS'))); 33var_dump(base64_encode(mb_convert_encoding($utf8_string, 'EUC-JP', 'UTF-8'))); 34 35echo "\n-- Convert to SJIS --\n"; 36echo "SJIS encoded string in base64:\n"; 37var_dump(base64_encode($sjis_string)); 38echo "Converted Strings:\n"; 39var_dump(base64_encode(mb_convert_encoding($jis_string, 'SJIS', 'JIS'))); 40var_dump(base64_encode(mb_convert_encoding($euc_jp_string, 'SJIS', 'EUC-JP'))); 41var_dump(base64_encode(mb_convert_encoding($utf8_string, 'SJIS', 'UTF-8'))); 42 43echo "\n-- Convert to UTF-8 --\n"; 44echo "UTF-8 encoded string in base64:\n"; 45var_dump(base64_encode($utf8_string)); 46echo "Converted Strings:\n"; 47var_dump(base64_encode(mb_convert_encoding($sjis_string, 'UTF-8', 'SJIS'))); 48var_dump(base64_encode(mb_convert_encoding($jis_string, 'UTF-8', 'JIS'))); 49var_dump(base64_encode(mb_convert_encoding($euc_jp_string, 'UTF-8', 'EUC-JP'))); 50 51echo "Done"; 52?> 53--EXPECT-- 54*** Testing mb_convert_encoding() : basic functionality *** 55 56-- Convert to JIS -- 57JIS encoded string in base64: 58string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==" 59Converted Strings: 60string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==" 61string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==" 62string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==" 63 64-- Convert to EUC-JP -- 65EUC-JP encoded string in base64: 66string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==" 67Converted Strings: 68string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==" 69string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==" 70string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==" 71 72-- Convert to SJIS -- 73SJIS encoded string in base64: 74string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==" 75Converted Strings: 76string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==" 77string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==" 78string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==" 79 80-- Convert to UTF-8 -- 81UTF-8 encoded string in base64: 82string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=" 83Converted Strings: 84string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=" 85string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=" 86string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=" 87Done 88