Annotation of embedaddon/php/ext/iconv/tests/iconv_substr.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: iconv_substr()
        !             3: --SKIPIF--
        !             4: <?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
        !             5: --INI--
        !             6: iconv.internal_charset=ISO-8859-1
        !             7: --FILE--
        !             8: <?php
        !             9: function hexdump($str) {
        !            10:        $len = strlen($str);
        !            11:        for ($i = 0; $i < $len; ++$i) {
        !            12:                printf("%02x", ord($str[$i]));
        !            13:        }
        !            14:        print "\n";
        !            15: }
        !            16: 
        !            17: function foo($str, $offset, $len, $charset) {
        !            18:        hexdump(substr($str, $offset, $len));
        !            19:        hexdump(iconv_substr($str, $offset, $len, $charset));
        !            20: }
        !            21: 
        !            22: function bar($str, $offset, $len = false) {
        !            23:        if (is_bool($len)) {
        !            24:                var_dump(substr($str, $offset));
        !            25:                var_dump(iconv_substr($str, $offset));
        !            26:        } else {
        !            27:                var_dump(substr($str, $offset, $len));
        !            28:                var_dump(iconv_substr($str, $offset, $len));
        !            29:        }
        !            30: }
        !            31: 
        !            32: foo("abcdefghijklmnopqrstuvwxyz", 5, 7, "ASCII");
        !            33: foo("あいうえおかきくけこさしす", 5, 7, "EUC-JP");
        !            34: bar("This is a test", 100000);
        !            35: bar("This is a test", 0, 100000);
        !            36: bar("This is a test", -3);
        !            37: bar("This is a test", 0, -9);
        !            38: bar("This is a test", 0, -100000);
        !            39: bar("This is a test", -9, -100000);
        !            40: var_dump(iconv("ISO-2022-JP", "EUC-JP", iconv_substr(iconv("EUC-JP", "ISO-2022-JP", "こんにちは ISO-2022-JP"), 3, 8, "ISO-2022-JP")));
        !            41: ?>
        !            42: --EXPECT--
        !            43: 666768696a6b6c
        !            44: 666768696a6b6c
        !            45: a6a4a8a4aaa4ab
        !            46: a4aba4ada4afa4b1a4b3a4b5a4b7
        !            47: bool(false)
        !            48: bool(false)
        !            49: string(14) "This is a test"
        !            50: string(14) "This is a test"
        !            51: string(3) "est"
        !            52: string(3) "est"
        !            53: string(5) "This "
        !            54: string(5) "This "
        !            55: bool(false)
        !            56: bool(false)
        !            57: bool(false)
        !            58: bool(false)
        !            59: string(10) "ちは ISO-2"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>