1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 12:13:02 +02:00
Files
archived-php-src/ext/iconv/tests/iconv_basic.phpt
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

73 lines
2.8 KiB
PHP

--TEST--
Test iconv() function : basic functionality
--SKIPIF--
<?php
extension_loaded('iconv') or die('skip');
function_exists('iconv') or die("skip iconv() is not available in this build");
?>
--FILE--
<?php
/* Prototype : string iconv(string in_charset, string out_charset, string str)
* Description: Returns converted string in desired encoding
* Source code: ext/iconv/iconv.c
*/
/*
* Test basic functionality of iconv()
*/
echo "*** Testing iconv() : basic functionality ***\n";
//All strings are the same when displayed in their respective encodings
$sjis_string = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
$euc_jp_string = base64_decode('xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==');
$utf8_string = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
echo "\n-- Convert to EUC-JP --\n";
echo "Expected EUC-JP encoded string in base64:\n";
var_dump(bin2hex($euc_jp_string));
echo "Converted Strings:\n";
var_dump(bin2hex(iconv('SJIS', 'EUC-JP', $sjis_string )));
var_dump(bin2hex(iconv('UTF-8', 'EUC-JP', $utf8_string)));
echo "\n-- Convert to SJIS --\n";
echo "Expected SJIS encoded string in base64:\n";
var_dump(bin2hex($sjis_string));
echo "Converted Strings:\n";
var_dump(bin2hex(iconv('EUC-JP', 'SJIS', $euc_jp_string)));
var_dump(bin2hex(iconv('UTF-8', 'SJIS', $utf8_string)));
echo "\n-- Convert to UTF-8 --\n";
echo "Expected UTF-8 encoded string in base64:\n";
var_dump(bin2hex($utf8_string));
echo "Converted Strings:\n";
var_dump(bin2hex(iconv('SJIS', 'UTF-8', $sjis_string)));
var_dump(bin2hex(iconv('EUC-JP', 'UTF-8', $euc_jp_string)));
echo "Done";
?>
--EXPECT--
*** Testing iconv() : basic functionality ***
-- Convert to EUC-JP --
Expected EUC-JP encoded string in base64:
string(74) "c6fccbdcb8eca5c6a5ada5b9a5c8a4c7a4b9a1a33031323334a3b5a3b6a3b7a3b8a3b9a1a3"
Converted Strings:
string(74) "c6fccbdcb8eca5c6a5ada5b9a5c8a4c7a4b9a1a33031323334a3b5a3b6a3b7a3b8a3b9a1a3"
string(74) "c6fccbdcb8eca5c6a5ada5b9a5c8a4c7a4b9a1a33031323334a3b5a3b6a3b7a3b8a3b9a1a3"
-- Convert to SJIS --
Expected SJIS encoded string in base64:
string(74) "93fa967b8cea8365834c8358836782c582b781423031323334825482558256825782588142"
Converted Strings:
string(74) "93fa967b8cea8365834c8358836782c582b781423031323334825482558256825782588142"
string(74) "93fa967b8cea8365834c8358836782c582b781423031323334825482558256825782588142"
-- Convert to UTF-8 --
Expected UTF-8 encoded string in base64:
string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082"
Converted Strings:
string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082"
string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082"
Done