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