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