Annotation of embedaddon/php/ext/mbstring/tests/mb_strlen_variation3.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test mb_strlen() function : usage variations - Pass list of encodings
        !             3: --SKIPIF--
        !             4: <?php
        !             5: extension_loaded('mbstring') or die('skip');
        !             6: function_exists('mb_strlen') or die("skip mb_strlen() is not available in this build");
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: /* Prototype  : int mb_strlen(string $str [, string $encoding])
        !            11:  * Description: Get character numbers of a string 
        !            12:  * Source code: ext/mbstring/mbstring.c
        !            13:  */
        !            14: 
        !            15: /*
        !            16:  * Pass all encodings listed on php.net to mb_strlen to test that function recognises them
        !            17:  * NB: The strings passed are *NOT* necessarily encoded in the encoding passed to the function.
        !            18:  * This test is purely to see whether the function recognises the encoding.
        !            19:  */
        !            20: 
        !            21: echo "*** Testing mb_strlen() : usage variations ***\n";
        !            22: 
        !            23: $encoding = array('UCS-4',                     /*1*/
        !            24:                   'UCS-4BE',
        !            25:                   'UCS-4LE',
        !            26:                   'UCS-2',
        !            27:                   'UCS-2BE',           /*5*/
        !            28:                   'UCS-2LE',
        !            29:                   'UTF-32',
        !            30:                   'UTF-32BE',
        !            31:                   'UTF-32LE',
        !            32:                   'UTF-16',                    /*10*/
        !            33:                   'UTF-16BE',
        !            34:                   'UTF-16LE',
        !            35:                   'UTF-7',
        !            36:                   'UTF7-IMAP',
        !            37:                   'UTF-8',                     /*15*/
        !            38:                   'ASCII',
        !            39:                   'EUC-JP',
        !            40:                   'SJIS',
        !            41:                   'eucJP-win',
        !            42:                   'SJIS-win',          /*20*/
        !            43:                   'ISO-2022-JP',
        !            44:                   'JIS',
        !            45:                   'ISO-8859-1',
        !            46:                   'ISO-8859-2',
        !            47:                   'ISO-8859-3',                /*25*/
        !            48:                   'ISO-8859-4',
        !            49:                   'ISO-8859-5',
        !            50:                   'ISO-8859-6',
        !            51:                   'ISO-8859-7',
        !            52:                   'ISO-8859-8',                /*30*/
        !            53:                   'ISO-8859-9',
        !            54:                   'ISO-8859-10',
        !            55:                   'ISO-8859-13',
        !            56:                   'ISO-8859-14',
        !            57:                   'ISO-8859-15',       /*35*/
        !            58:                   'byte2be',
        !            59:                   'byte2le',
        !            60:                   'byte4be',
        !            61:                   'byte4le',
        !            62:                   'BASE64',                    /*40*/
        !            63:                   'HTML-ENTITIES',
        !            64:                   '7bit',
        !            65:                   '8bit',
        !            66:                   'EUC-CN',
        !            67:                   'CP936',                     /*45*/
        !            68:                   'HZ',
        !            69:                   'EUC-TW',
        !            70:                   'CP950',
        !            71:                   'BIG-5',
        !            72:                   'EUC-KR',                    /*50*/
        !            73:                   'UHC',
        !            74:                   'ISO-2022-KR',
        !            75:                   'Windows-1251',
        !            76:                   'Windows-1252',
        !            77:                   'CP866',                     /*55*/
        !            78:                   'KOI8-R');           /*56*/
        !            79: 
        !            80: 
        !            81: 
        !            82: $iterator = 1;
        !            83: $string_ascii = 'abc def';
        !            84: $string_mb = base64_decode('44K/44OT44Ol44Os44O844OG44Kj44Oz44Kw44O744Oe44K344O844Oz44O744Kr44Oz44OR44OL44O8');
        !            85: 
        !            86: foreach($encoding as $enc) {
        !            87:        echo "\n-- Iteration $iterator: $enc --\n";
        !            88: 
        !            89:        echo "-- ASCII String --\n";
        !            90:        if(mb_strlen($string_ascii, $enc)) {
        !            91:                echo "Encoding $enc recognised\n";
        !            92:        } else {
        !            93:                echo "Encoding $enc not recognised\n";
        !            94:        }
        !            95: 
        !            96:        echo "-- Multibyte String --\n";
        !            97:        if(mb_strlen($string_mb, $enc)){
        !            98:                echo "Encoding $enc recognised\n";
        !            99:        } else {
        !           100:                echo "Encoding $enc not recognised\n";
        !           101:        }
        !           102:        $iterator++;
        !           103: }
        !           104: 
        !           105: echo "Done";
        !           106: ?>
        !           107: --EXPECTF--
        !           108: *** Testing mb_strlen() : usage variations ***
        !           109: 
        !           110: -- Iteration 1: UCS-4 --
        !           111: -- ASCII String --
        !           112: Encoding UCS-4 recognised
        !           113: -- Multibyte String --
        !           114: Encoding UCS-4 recognised
        !           115: 
        !           116: -- Iteration 2: UCS-4BE --
        !           117: -- ASCII String --
        !           118: Encoding UCS-4BE recognised
        !           119: -- Multibyte String --
        !           120: Encoding UCS-4BE recognised
        !           121: 
        !           122: -- Iteration 3: UCS-4LE --
        !           123: -- ASCII String --
        !           124: Encoding UCS-4LE recognised
        !           125: -- Multibyte String --
        !           126: Encoding UCS-4LE recognised
        !           127: 
        !           128: -- Iteration 4: UCS-2 --
        !           129: -- ASCII String --
        !           130: Encoding UCS-2 recognised
        !           131: -- Multibyte String --
        !           132: Encoding UCS-2 recognised
        !           133: 
        !           134: -- Iteration 5: UCS-2BE --
        !           135: -- ASCII String --
        !           136: Encoding UCS-2BE recognised
        !           137: -- Multibyte String --
        !           138: Encoding UCS-2BE recognised
        !           139: 
        !           140: -- Iteration 6: UCS-2LE --
        !           141: -- ASCII String --
        !           142: Encoding UCS-2LE recognised
        !           143: -- Multibyte String --
        !           144: Encoding UCS-2LE recognised
        !           145: 
        !           146: -- Iteration 7: UTF-32 --
        !           147: -- ASCII String --
        !           148: Encoding UTF-32 recognised
        !           149: -- Multibyte String --
        !           150: Encoding UTF-32 recognised
        !           151: 
        !           152: -- Iteration 8: UTF-32BE --
        !           153: -- ASCII String --
        !           154: Encoding UTF-32BE recognised
        !           155: -- Multibyte String --
        !           156: Encoding UTF-32BE recognised
        !           157: 
        !           158: -- Iteration 9: UTF-32LE --
        !           159: -- ASCII String --
        !           160: Encoding UTF-32LE recognised
        !           161: -- Multibyte String --
        !           162: Encoding UTF-32LE recognised
        !           163: 
        !           164: -- Iteration 10: UTF-16 --
        !           165: -- ASCII String --
        !           166: Encoding UTF-16 recognised
        !           167: -- Multibyte String --
        !           168: Encoding UTF-16 recognised
        !           169: 
        !           170: -- Iteration 11: UTF-16BE --
        !           171: -- ASCII String --
        !           172: Encoding UTF-16BE recognised
        !           173: -- Multibyte String --
        !           174: Encoding UTF-16BE recognised
        !           175: 
        !           176: -- Iteration 12: UTF-16LE --
        !           177: -- ASCII String --
        !           178: Encoding UTF-16LE recognised
        !           179: -- Multibyte String --
        !           180: Encoding UTF-16LE recognised
        !           181: 
        !           182: -- Iteration 13: UTF-7 --
        !           183: -- ASCII String --
        !           184: Encoding UTF-7 recognised
        !           185: -- Multibyte String --
        !           186: Encoding UTF-7 recognised
        !           187: 
        !           188: -- Iteration 14: UTF7-IMAP --
        !           189: -- ASCII String --
        !           190: Encoding UTF7-IMAP recognised
        !           191: -- Multibyte String --
        !           192: Encoding UTF7-IMAP recognised
        !           193: 
        !           194: -- Iteration 15: UTF-8 --
        !           195: -- ASCII String --
        !           196: Encoding UTF-8 recognised
        !           197: -- Multibyte String --
        !           198: Encoding UTF-8 recognised
        !           199: 
        !           200: -- Iteration 16: ASCII --
        !           201: -- ASCII String --
        !           202: Encoding ASCII recognised
        !           203: -- Multibyte String --
        !           204: Encoding ASCII recognised
        !           205: 
        !           206: -- Iteration 17: EUC-JP --
        !           207: -- ASCII String --
        !           208: Encoding EUC-JP recognised
        !           209: -- Multibyte String --
        !           210: Encoding EUC-JP recognised
        !           211: 
        !           212: -- Iteration 18: SJIS --
        !           213: -- ASCII String --
        !           214: Encoding SJIS recognised
        !           215: -- Multibyte String --
        !           216: Encoding SJIS recognised
        !           217: 
        !           218: -- Iteration 19: eucJP-win --
        !           219: -- ASCII String --
        !           220: Encoding eucJP-win recognised
        !           221: -- Multibyte String --
        !           222: Encoding eucJP-win recognised
        !           223: 
        !           224: -- Iteration 20: SJIS-win --
        !           225: -- ASCII String --
        !           226: Encoding SJIS-win recognised
        !           227: -- Multibyte String --
        !           228: Encoding SJIS-win recognised
        !           229: 
        !           230: -- Iteration 21: ISO-2022-JP --
        !           231: -- ASCII String --
        !           232: Encoding ISO-2022-JP recognised
        !           233: -- Multibyte String --
        !           234: Encoding ISO-2022-JP recognised
        !           235: 
        !           236: -- Iteration 22: JIS --
        !           237: -- ASCII String --
        !           238: Encoding JIS recognised
        !           239: -- Multibyte String --
        !           240: Encoding JIS recognised
        !           241: 
        !           242: -- Iteration 23: ISO-8859-1 --
        !           243: -- ASCII String --
        !           244: Encoding ISO-8859-1 recognised
        !           245: -- Multibyte String --
        !           246: Encoding ISO-8859-1 recognised
        !           247: 
        !           248: -- Iteration 24: ISO-8859-2 --
        !           249: -- ASCII String --
        !           250: Encoding ISO-8859-2 recognised
        !           251: -- Multibyte String --
        !           252: Encoding ISO-8859-2 recognised
        !           253: 
        !           254: -- Iteration 25: ISO-8859-3 --
        !           255: -- ASCII String --
        !           256: Encoding ISO-8859-3 recognised
        !           257: -- Multibyte String --
        !           258: Encoding ISO-8859-3 recognised
        !           259: 
        !           260: -- Iteration 26: ISO-8859-4 --
        !           261: -- ASCII String --
        !           262: Encoding ISO-8859-4 recognised
        !           263: -- Multibyte String --
        !           264: Encoding ISO-8859-4 recognised
        !           265: 
        !           266: -- Iteration 27: ISO-8859-5 --
        !           267: -- ASCII String --
        !           268: Encoding ISO-8859-5 recognised
        !           269: -- Multibyte String --
        !           270: Encoding ISO-8859-5 recognised
        !           271: 
        !           272: -- Iteration 28: ISO-8859-6 --
        !           273: -- ASCII String --
        !           274: Encoding ISO-8859-6 recognised
        !           275: -- Multibyte String --
        !           276: Encoding ISO-8859-6 recognised
        !           277: 
        !           278: -- Iteration 29: ISO-8859-7 --
        !           279: -- ASCII String --
        !           280: Encoding ISO-8859-7 recognised
        !           281: -- Multibyte String --
        !           282: Encoding ISO-8859-7 recognised
        !           283: 
        !           284: -- Iteration 30: ISO-8859-8 --
        !           285: -- ASCII String --
        !           286: Encoding ISO-8859-8 recognised
        !           287: -- Multibyte String --
        !           288: Encoding ISO-8859-8 recognised
        !           289: 
        !           290: -- Iteration 31: ISO-8859-9 --
        !           291: -- ASCII String --
        !           292: Encoding ISO-8859-9 recognised
        !           293: -- Multibyte String --
        !           294: Encoding ISO-8859-9 recognised
        !           295: 
        !           296: -- Iteration 32: ISO-8859-10 --
        !           297: -- ASCII String --
        !           298: Encoding ISO-8859-10 recognised
        !           299: -- Multibyte String --
        !           300: Encoding ISO-8859-10 recognised
        !           301: 
        !           302: -- Iteration 33: ISO-8859-13 --
        !           303: -- ASCII String --
        !           304: Encoding ISO-8859-13 recognised
        !           305: -- Multibyte String --
        !           306: Encoding ISO-8859-13 recognised
        !           307: 
        !           308: -- Iteration 34: ISO-8859-14 --
        !           309: -- ASCII String --
        !           310: Encoding ISO-8859-14 recognised
        !           311: -- Multibyte String --
        !           312: Encoding ISO-8859-14 recognised
        !           313: 
        !           314: -- Iteration 35: ISO-8859-15 --
        !           315: -- ASCII String --
        !           316: Encoding ISO-8859-15 recognised
        !           317: -- Multibyte String --
        !           318: Encoding ISO-8859-15 recognised
        !           319: 
        !           320: -- Iteration 36: byte2be --
        !           321: -- ASCII String --
        !           322: Encoding byte2be recognised
        !           323: -- Multibyte String --
        !           324: Encoding byte2be recognised
        !           325: 
        !           326: -- Iteration 37: byte2le --
        !           327: -- ASCII String --
        !           328: Encoding byte2le recognised
        !           329: -- Multibyte String --
        !           330: Encoding byte2le recognised
        !           331: 
        !           332: -- Iteration 38: byte4be --
        !           333: -- ASCII String --
        !           334: Encoding byte4be recognised
        !           335: -- Multibyte String --
        !           336: Encoding byte4be recognised
        !           337: 
        !           338: -- Iteration 39: byte4le --
        !           339: -- ASCII String --
        !           340: Encoding byte4le recognised
        !           341: -- Multibyte String --
        !           342: Encoding byte4le recognised
        !           343: 
        !           344: -- Iteration 40: BASE64 --
        !           345: -- ASCII String --
        !           346: Encoding BASE64 recognised
        !           347: -- Multibyte String --
        !           348: Encoding BASE64 recognised
        !           349: 
        !           350: -- Iteration 41: HTML-ENTITIES --
        !           351: -- ASCII String --
        !           352: Encoding HTML-ENTITIES recognised
        !           353: -- Multibyte String --
        !           354: Encoding HTML-ENTITIES recognised
        !           355: 
        !           356: -- Iteration 42: 7bit --
        !           357: -- ASCII String --
        !           358: Encoding 7bit recognised
        !           359: -- Multibyte String --
        !           360: Encoding 7bit recognised
        !           361: 
        !           362: -- Iteration 43: 8bit --
        !           363: -- ASCII String --
        !           364: Encoding 8bit recognised
        !           365: -- Multibyte String --
        !           366: Encoding 8bit recognised
        !           367: 
        !           368: -- Iteration 44: EUC-CN --
        !           369: -- ASCII String --
        !           370: Encoding EUC-CN recognised
        !           371: -- Multibyte String --
        !           372: Encoding EUC-CN recognised
        !           373: 
        !           374: -- Iteration 45: CP936 --
        !           375: -- ASCII String --
        !           376: Encoding CP936 recognised
        !           377: -- Multibyte String --
        !           378: Encoding CP936 recognised
        !           379: 
        !           380: -- Iteration 46: HZ --
        !           381: -- ASCII String --
        !           382: Encoding HZ recognised
        !           383: -- Multibyte String --
        !           384: Encoding HZ recognised
        !           385: 
        !           386: -- Iteration 47: EUC-TW --
        !           387: -- ASCII String --
        !           388: Encoding EUC-TW recognised
        !           389: -- Multibyte String --
        !           390: Encoding EUC-TW recognised
        !           391: 
        !           392: -- Iteration 48: CP950 --
        !           393: -- ASCII String --
        !           394: Encoding CP950 recognised
        !           395: -- Multibyte String --
        !           396: Encoding CP950 recognised
        !           397: 
        !           398: -- Iteration 49: BIG-5 --
        !           399: -- ASCII String --
        !           400: Encoding BIG-5 recognised
        !           401: -- Multibyte String --
        !           402: Encoding BIG-5 recognised
        !           403: 
        !           404: -- Iteration 50: EUC-KR --
        !           405: -- ASCII String --
        !           406: Encoding EUC-KR recognised
        !           407: -- Multibyte String --
        !           408: Encoding EUC-KR recognised
        !           409: 
        !           410: -- Iteration 51: UHC --
        !           411: -- ASCII String --
        !           412: Encoding UHC recognised
        !           413: -- Multibyte String --
        !           414: Encoding UHC recognised
        !           415: 
        !           416: -- Iteration 52: ISO-2022-KR --
        !           417: -- ASCII String --
        !           418: Encoding ISO-2022-KR recognised
        !           419: -- Multibyte String --
        !           420: Encoding ISO-2022-KR recognised
        !           421: 
        !           422: -- Iteration 53: Windows-1251 --
        !           423: -- ASCII String --
        !           424: Encoding Windows-1251 recognised
        !           425: -- Multibyte String --
        !           426: Encoding Windows-1251 recognised
        !           427: 
        !           428: -- Iteration 54: Windows-1252 --
        !           429: -- ASCII String --
        !           430: Encoding Windows-1252 recognised
        !           431: -- Multibyte String --
        !           432: Encoding Windows-1252 recognised
        !           433: 
        !           434: -- Iteration 55: CP866 --
        !           435: -- ASCII String --
        !           436: Encoding CP866 recognised
        !           437: -- Multibyte String --
        !           438: Encoding CP866 recognised
        !           439: 
        !           440: -- Iteration 56: KOI8-R --
        !           441: -- ASCII String --
        !           442: Encoding KOI8-R recognised
        !           443: -- Multibyte String --
        !           444: Encoding KOI8-R recognised
        !           445: Done

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