StringTest.php 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  11. * @since 1.2.0
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Cake\Test\TestCase\Utility;
  15. use Cake\TestSuite\TestCase;
  16. use Cake\Utility\String;
  17. /**
  18. * StringTest class
  19. *
  20. */
  21. class StringTest extends TestCase
  22. {
  23. public function setUp()
  24. {
  25. parent::setUp();
  26. $this->encoding = mb_internal_encoding();
  27. $this->Text = new String();
  28. }
  29. public function tearDown()
  30. {
  31. parent::tearDown();
  32. mb_internal_encoding($this->encoding);
  33. unset($this->Text);
  34. }
  35. /**
  36. * testUuidGeneration method
  37. *
  38. * @return void
  39. */
  40. public function testUuidGeneration()
  41. {
  42. $result = String::uuid();
  43. $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
  44. $match = (bool)preg_match($pattern, $result);
  45. $this->assertTrue($match);
  46. }
  47. /**
  48. * testMultipleUuidGeneration method
  49. *
  50. * @return void
  51. */
  52. public function testMultipleUuidGeneration()
  53. {
  54. $check = [];
  55. $count = mt_rand(10, 1000);
  56. $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
  57. for ($i = 0; $i < $count; $i++) {
  58. $result = String::uuid();
  59. $match = (bool)preg_match($pattern, $result);
  60. $this->assertTrue($match);
  61. $this->assertFalse(in_array($result, $check));
  62. $check[] = $result;
  63. }
  64. }
  65. /**
  66. * testInsert method
  67. *
  68. * @return void
  69. */
  70. public function testInsert()
  71. {
  72. $string = 'some string';
  73. $expected = 'some string';
  74. $result = String::insert($string, []);
  75. $this->assertEquals($expected, $result);
  76. $string = '2 + 2 = :sum. Cake is :adjective.';
  77. $expected = '2 + 2 = 4. Cake is yummy.';
  78. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy']);
  79. $this->assertEquals($expected, $result);
  80. $string = '2 + 2 = %sum. Cake is %adjective.';
  81. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['before' => '%']);
  82. $this->assertEquals($expected, $result);
  83. $string = '2 + 2 = 2sum2. Cake is 9adjective9.';
  84. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['format' => '/([\d])%s\\1/']);
  85. $this->assertEquals($expected, $result);
  86. $string = '2 + 2 = 12sum21. Cake is 23adjective45.';
  87. $expected = '2 + 2 = 4. Cake is 23adjective45.';
  88. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['format' => '/([\d])([\d])%s\\2\\1/']);
  89. $this->assertEquals($expected, $result);
  90. $string = ':web :web_site';
  91. $expected = 'www http';
  92. $result = String::insert($string, ['web' => 'www', 'web_site' => 'http']);
  93. $this->assertEquals($expected, $result);
  94. $string = '2 + 2 = <sum. Cake is <adjective>.';
  95. $expected = '2 + 2 = <sum. Cake is yummy.';
  96. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['before' => '<', 'after' => '>']);
  97. $this->assertEquals($expected, $result);
  98. $string = '2 + 2 = \:sum. Cake is :adjective.';
  99. $expected = '2 + 2 = :sum. Cake is yummy.';
  100. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy']);
  101. $this->assertEquals($expected, $result);
  102. $string = '2 + 2 = !:sum. Cake is :adjective.';
  103. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['escape' => '!']);
  104. $this->assertEquals($expected, $result);
  105. $string = '2 + 2 = \%sum. Cake is %adjective.';
  106. $expected = '2 + 2 = %sum. Cake is yummy.';
  107. $result = String::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['before' => '%']);
  108. $this->assertEquals($expected, $result);
  109. $string = ':a :b \:a :a';
  110. $expected = '1 2 :a 1';
  111. $result = String::insert($string, ['a' => 1, 'b' => 2]);
  112. $this->assertEquals($expected, $result);
  113. $string = ':a :b :c';
  114. $expected = '2 3';
  115. $result = String::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
  116. $this->assertEquals($expected, $result);
  117. $string = ':a :b :c';
  118. $expected = '1 3';
  119. $result = String::insert($string, ['a' => 1, 'c' => 3], ['clean' => true]);
  120. $this->assertEquals($expected, $result);
  121. $string = ':a :b :c';
  122. $expected = '2 3';
  123. $result = String::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
  124. $this->assertEquals($expected, $result);
  125. $string = ':a, :b and :c';
  126. $expected = '2 and 3';
  127. $result = String::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
  128. $this->assertEquals($expected, $result);
  129. $string = '":a, :b and :c"';
  130. $expected = '"1, 2"';
  131. $result = String::insert($string, ['a' => 1, 'b' => 2], ['clean' => true]);
  132. $this->assertEquals($expected, $result);
  133. $string = '"${a}, ${b} and ${c}"';
  134. $expected = '"1, 2"';
  135. $result = String::insert($string, ['a' => 1, 'b' => 2], ['before' => '${', 'after' => '}', 'clean' => true]);
  136. $this->assertEquals($expected, $result);
  137. $string = '<img src=":src" alt=":alt" class="foo :extra bar"/>';
  138. $expected = '<img src="foo" class="foo bar"/>';
  139. $result = String::insert($string, ['src' => 'foo'], ['clean' => 'html']);
  140. $this->assertEquals($expected, $result);
  141. $string = '<img src=":src" class=":no :extra"/>';
  142. $expected = '<img src="foo"/>';
  143. $result = String::insert($string, ['src' => 'foo'], ['clean' => 'html']);
  144. $this->assertEquals($expected, $result);
  145. $string = '<img src=":src" class=":no :extra"/>';
  146. $expected = '<img src="foo" class="bar"/>';
  147. $result = String::insert($string, ['src' => 'foo', 'extra' => 'bar'], ['clean' => 'html']);
  148. $this->assertEquals($expected, $result);
  149. $result = String::insert("this is a ? string", "test");
  150. $expected = "this is a test string";
  151. $this->assertEquals($expected, $result);
  152. $result = String::insert("this is a ? string with a ? ? ?", ['long', 'few?', 'params', 'you know']);
  153. $expected = "this is a long string with a few? params you know";
  154. $this->assertEquals($expected, $result);
  155. $result = String::insert('update saved_urls set url = :url where id = :id', ['url' => 'http://www.testurl.com/param1:url/param2:id', 'id' => 1]);
  156. $expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1";
  157. $this->assertEquals($expected, $result);
  158. $result = String::insert('update saved_urls set url = :url where id = :id', ['id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id']);
  159. $expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1";
  160. $this->assertEquals($expected, $result);
  161. $result = String::insert(':me cake. :subject :verb fantastic.', ['me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is']);
  162. $expected = "I :verb cake. cake is fantastic.";
  163. $this->assertEquals($expected, $result);
  164. $result = String::insert(':I.am: :not.yet: passing.', ['I.am' => 'We are'], ['before' => ':', 'after' => ':', 'clean' => ['replacement' => ' of course', 'method' => 'text']]);
  165. $expected = "We are of course passing.";
  166. $this->assertEquals($expected, $result);
  167. $result = String::insert(
  168. ':I.am: :not.yet: passing.',
  169. ['I.am' => 'We are'],
  170. ['before' => ':', 'after' => ':', 'clean' => true]
  171. );
  172. $expected = "We are passing.";
  173. $this->assertEquals($expected, $result);
  174. $result = String::insert('?-pended result', ['Pre']);
  175. $expected = "Pre-pended result";
  176. $this->assertEquals($expected, $result);
  177. $string = 'switching :timeout / :timeout_count';
  178. $expected = 'switching 5 / 10';
  179. $result = String::insert($string, ['timeout' => 5, 'timeout_count' => 10]);
  180. $this->assertEquals($expected, $result);
  181. $string = 'switching :timeout / :timeout_count';
  182. $expected = 'switching 5 / 10';
  183. $result = String::insert($string, ['timeout_count' => 10, 'timeout' => 5]);
  184. $this->assertEquals($expected, $result);
  185. $string = 'switching :timeout_count by :timeout';
  186. $expected = 'switching 10 by 5';
  187. $result = String::insert($string, ['timeout' => 5, 'timeout_count' => 10]);
  188. $this->assertEquals($expected, $result);
  189. $string = 'switching :timeout_count by :timeout';
  190. $expected = 'switching 10 by 5';
  191. $result = String::insert($string, ['timeout_count' => 10, 'timeout' => 5]);
  192. $this->assertEquals($expected, $result);
  193. }
  194. /**
  195. * test Clean Insert
  196. *
  197. * @return void
  198. */
  199. public function testCleanInsert()
  200. {
  201. $result = String::cleanInsert(':incomplete', [
  202. 'clean' => true, 'before' => ':', 'after' => ''
  203. ]);
  204. $this->assertEquals('', $result);
  205. $result = String::cleanInsert(
  206. ':incomplete',
  207. [
  208. 'clean' => ['method' => 'text', 'replacement' => 'complete'],
  209. 'before' => ':', 'after' => '']
  210. );
  211. $this->assertEquals('complete', $result);
  212. $result = String::cleanInsert(':in.complete', [
  213. 'clean' => true, 'before' => ':', 'after' => ''
  214. ]);
  215. $this->assertEquals('', $result);
  216. $result = String::cleanInsert(
  217. ':in.complete and',
  218. [
  219. 'clean' => true, 'before' => ':', 'after' => '']
  220. );
  221. $this->assertEquals('', $result);
  222. $result = String::cleanInsert(':in.complete or stuff', [
  223. 'clean' => true, 'before' => ':', 'after' => ''
  224. ]);
  225. $this->assertEquals('stuff', $result);
  226. $result = String::cleanInsert(
  227. '<p class=":missing" id=":missing">Text here</p>',
  228. ['clean' => 'html', 'before' => ':', 'after' => '']
  229. );
  230. $this->assertEquals('<p>Text here</p>', $result);
  231. }
  232. /**
  233. * Tests that non-insertable variables (i.e. arrays) are skipped when used as values in
  234. * String::insert().
  235. *
  236. * @return void
  237. */
  238. public function testAutoIgnoreBadInsertData()
  239. {
  240. $data = ['foo' => 'alpha', 'bar' => 'beta', 'fale' => []];
  241. $result = String::insert('(:foo > :bar || :fale!)', $data, ['clean' => 'text']);
  242. $this->assertEquals('(alpha > beta || !)', $result);
  243. }
  244. /**
  245. * testTokenize method
  246. *
  247. * @return void
  248. */
  249. public function testTokenize()
  250. {
  251. $result = String::tokenize('A,(short,boring test)');
  252. $expected = ['A', '(short,boring test)'];
  253. $this->assertEquals($expected, $result);
  254. $result = String::tokenize('A,(short,more interesting( test)');
  255. $expected = ['A', '(short,more interesting( test)'];
  256. $this->assertEquals($expected, $result);
  257. $result = String::tokenize('A,(short,very interesting( test))');
  258. $expected = ['A', '(short,very interesting( test))'];
  259. $this->assertEquals($expected, $result);
  260. $result = String::tokenize('"single tag"', ' ', '"', '"');
  261. $expected = ['"single tag"'];
  262. $this->assertEquals($expected, $result);
  263. $result = String::tokenize('tagA "single tag" tagB', ' ', '"', '"');
  264. $expected = ['tagA', '"single tag"', 'tagB'];
  265. $this->assertEquals($expected, $result);
  266. }
  267. public function testReplaceWithQuestionMarkInString()
  268. {
  269. $string = ':a, :b and :c?';
  270. $expected = '2 and 3?';
  271. $result = String::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
  272. $this->assertEquals($expected, $result);
  273. }
  274. /**
  275. * test that wordWrap() works the same as built-in wordwrap function
  276. *
  277. * @dataProvider wordWrapProvider
  278. * @return void
  279. */
  280. public function testWordWrap($text, $width, $break = "\n", $cut = false)
  281. {
  282. $result = String::wordWrap($text, $width, $break, $cut);
  283. $expected = wordwrap($text, $width, $break, $cut);
  284. $this->assertTextEquals($expected, $result, 'Text not wrapped same as built-in function.');
  285. }
  286. /**
  287. * data provider for testWordWrap method
  288. *
  289. * @return array
  290. */
  291. public function wordWrapProvider()
  292. {
  293. return [
  294. [
  295. 'The quick brown fox jumped over the lazy dog.',
  296. 33
  297. ],
  298. [
  299. 'A very long woooooooooooord.',
  300. 8
  301. ],
  302. [
  303. 'A very long woooooooooooord. Right.',
  304. 8
  305. ],
  306. ];
  307. }
  308. /**
  309. * test that wordWrap() properly handle unicode strings.
  310. *
  311. * @return void
  312. */
  313. public function testWordWrapUnicodeAware()
  314. {
  315. $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.';
  316. $result = String::wordWrap($text, 33, "\n", true);
  317. $expected = <<<TEXT
  318. Но вим омниюм факёльиси элыктрам,
  319. мюнырэ лэгыры векж ыт. Выльёт квю
  320. андо нюмквуам ты кюм. Зыд эю рыбю
  321. м.
  322. TEXT;
  323. $this->assertTextEquals($expected, $result, 'Text not wrapped.');
  324. $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.';
  325. $result = String::wordWrap($text, 33, "\n");
  326. $expected = <<<TEXT
  327. Но вим омниюм факёльиси элыктрам,
  328. мюнырэ лэгыры векж ыт. Выльёт
  329. квюандо нюмквуам ты кюм. Зыд эю
  330. рыбюм.
  331. TEXT;
  332. $this->assertTextEquals($expected, $result, 'Text not wrapped.');
  333. }
  334. /**
  335. * test wrap method.
  336. *
  337. * @return void
  338. */
  339. public function testWrap()
  340. {
  341. $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.';
  342. $result = String::wrap($text, 33);
  343. $expected = <<<TEXT
  344. This is the song that never ends.
  345. This is the song that never ends.
  346. This is the song that never ends.
  347. TEXT;
  348. $this->assertTextEquals($expected, $result, 'Text not wrapped.');
  349. $result = String::wrap($text, ['width' => 20, 'wordWrap' => false]);
  350. $expected = <<<TEXT
  351. This is the song th
  352. at never ends. This
  353. is the song that n
  354. ever ends. This is
  355. the song that never
  356. ends.
  357. TEXT;
  358. $this->assertTextEquals($expected, $result, 'Text not wrapped.');
  359. }
  360. /**
  361. * test wrap() indenting
  362. *
  363. * @return void
  364. */
  365. public function testWrapIndent()
  366. {
  367. $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.';
  368. $result = String::wrap($text, ['width' => 33, 'indent' => "\t", 'indentAt' => 1]);
  369. $expected = <<<TEXT
  370. This is the song that never ends.
  371. This is the song that never ends.
  372. This is the song that never ends.
  373. TEXT;
  374. $this->assertTextEquals($expected, $result);
  375. }
  376. /**
  377. * testTruncate method
  378. *
  379. * @return void
  380. */
  381. public function testTruncate()
  382. {
  383. $text1 = 'The quick brown fox jumps over the lazy dog';
  384. $text2 = 'Heiz&ouml;lr&uuml;cksto&szlig;abd&auml;mpfung';
  385. $text3 = '<b>&copy; 2005-2007, Cake Software Foundation, Inc.</b><br />written by Alexander Wegener';
  386. $text4 = '<img src="mypic.jpg"> This image tag is not XHTML conform!<br><hr/><b>But the following image tag should be conform <img src="mypic.jpg" alt="Me, myself and I" /></b><br />Great, or?';
  387. $text5 = '0<b>1<i>2<span class="myclass">3</span>4<u>5</u>6</i>7</b>8<b>9</b>0';
  388. $text6 = '<p><strong>Extra dates have been announced for this year\'s tour.</strong></p><p>Tickets for the new shows in</p>';
  389. $text7 = 'El moño está en el lugar correcto. Eso fue lo que dijo la niña, ¿habrá dicho la verdad?';
  390. $text8 = 'Vive la R' . chr(195) . chr(169) . 'publique de France';
  391. $text9 = 'НОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь';
  392. $text10 = 'http://example.com/something/foo:bar';
  393. $this->assertSame($this->Text->truncate($text1, 15), 'The quick br...');
  394. $this->assertSame($this->Text->truncate($text1, 15, ['exact' => false]), 'The quick...');
  395. $this->assertSame($this->Text->truncate($text1, 100), 'The quick brown fox jumps over the lazy dog');
  396. $this->assertSame($this->Text->truncate($text2, 10), 'Heiz&ou...');
  397. $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false]), '...');
  398. $this->assertSame($this->Text->truncate($text3, 20), '<b>&copy; 2005-20...');
  399. $this->assertSame($this->Text->truncate($text4, 15), '<img src="my...');
  400. $this->assertSame($this->Text->truncate($text5, 6, ['ellipsis' => '']), '0<b>1<');
  401. $this->assertSame($this->Text->truncate($text1, 15, ['html' => true]), "The quick brow\xe2\x80\xa6");
  402. $this->assertSame($this->Text->truncate($text1, 15, ['exact' => false, 'html' => true]), "The quick\xe2\x80\xa6");
  403. $this->assertSame($this->Text->truncate($text2, 10, ['html' => true]), "Heiz&ouml;lr&uuml;c\xe2\x80\xa6");
  404. $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false, 'html' => true]), "\xe2\x80\xa6");
  405. $this->assertSame($this->Text->truncate($text3, 20, ['html' => true]), "<b>&copy; 2005-2007, Cake S\xe2\x80\xa6</b>");
  406. $this->assertSame($this->Text->truncate($text4, 15, ['html' => true]), "<img src=\"mypic.jpg\"> This image ta\xe2\x80\xa6");
  407. $this->assertSame($this->Text->truncate($text4, 45, ['html' => true]), "<img src=\"mypic.jpg\"> This image tag is not XHTML conform!<br><hr/><b>But the\xe2\x80\xa6</b>");
  408. $this->assertSame($this->Text->truncate($text4, 90, ['html' => true]), '<img src="mypic.jpg"> This image tag is not XHTML conform!<br><hr/><b>But the following image tag should be conform <img src="mypic.jpg" alt="Me, myself and I" /></b><br />Great,' . "\xe2\x80\xa6");
  409. $this->assertSame($this->Text->truncate($text5, 6, ['ellipsis' => '', 'html' => true]), '0<b>1<i>2<span class="myclass">3</span>4<u>5</u></i></b>');
  410. $this->assertSame($this->Text->truncate($text5, 20, ['ellipsis' => '', 'html' => true]), $text5);
  411. $this->assertSame($this->Text->truncate($text6, 57, ['exact' => false, 'html' => true]), "<p><strong>Extra dates have been announced for this year's\xe2\x80\xa6</strong></p>");
  412. $this->assertSame($this->Text->truncate($text7, 255), $text7);
  413. $this->assertSame($this->Text->truncate($text7, 15), 'El moño está...');
  414. $this->assertSame($this->Text->truncate($text8, 15), 'Vive la R' . chr(195) . chr(169) . 'pu...');
  415. $this->assertSame($this->Text->truncate($text9, 10), 'НОПРСТУ...');
  416. $this->assertSame($this->Text->truncate($text10, 30), 'http://example.com/somethin...');
  417. $text = '<p><span style="font-size: medium;"><a>Iamatestwithnospacesandhtml</a></span></p>';
  418. $result = $this->Text->truncate($text, 10, [
  419. 'ellipsis' => '...',
  420. 'exact' => false,
  421. 'html' => true
  422. ]);
  423. $expected = '<p><span style="font-size: medium;"><a>...</a></span></p>';
  424. $this->assertEquals($expected, $result);
  425. $text = '<p><span style="font-size: medium;">El biógrafo de Steve Jobs, Walter
  426. Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en
  427. este artículo de El País.</span></p>
  428. <p><span style="font-size: medium;"><span style="font-size:
  429. large;">Por qué Steve era distinto.</span></span></p>
  430. <p><span style="font-size: medium;"><a href="http://www.elpais.com/
  431. articulo/primer/plano/Steve/era/distinto/elpepueconeg/
  432. 20111009elpneglse_4/Tes">http://www.elpais.com/articulo/primer/plano/
  433. Steve/era/distinto/elpepueconeg/20111009elpneglse_4/Tes</a></span></p>
  434. <p><span style="font-size: medium;">Ya se ha publicado la biografía de
  435. Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter
  436. Isaacson</strong>", aquí os dejamos la dirección de amazon donde
  437. podeís adquirirla.</span></p>
  438. <p><span style="font-size: medium;"><a>http://www.amazon.com/Steve-
  439. Jobs-Walter-Isaacson/dp/1451648537</a></span></p>';
  440. $result = $this->Text->truncate($text, 500, [
  441. 'ellipsis' => '... ',
  442. 'exact' => false,
  443. 'html' => true
  444. ]);
  445. $expected = '<p><span style="font-size: medium;">El biógrafo de Steve Jobs, Walter
  446. Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en
  447. este artículo de El País.</span></p>
  448. <p><span style="font-size: medium;"><span style="font-size:
  449. large;">Por qué Steve era distinto.</span></span></p>
  450. <p><span style="font-size: medium;"><a href="http://www.elpais.com/
  451. articulo/primer/plano/Steve/era/distinto/elpepueconeg/
  452. 20111009elpneglse_4/Tes">http://www.elpais.com/articulo/primer/plano/
  453. Steve/era/distinto/elpepueconeg/20111009elpneglse_4/Tes</a></span></p>
  454. <p><span style="font-size: medium;">Ya se ha publicado la biografía de
  455. Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter
  456. Isaacson</strong>", aquí os dejamos la dirección de amazon donde
  457. podeís adquirirla.</span></p>
  458. <p><span style="font-size: medium;"><a>... </a></span></p>';
  459. $this->assertEquals($expected, $result);
  460. }
  461. /**
  462. * testTruncate method with non utf8 sites
  463. *
  464. * @return void
  465. */
  466. public function testTruncateLegacy()
  467. {
  468. mb_internal_encoding('ISO-8859-1');
  469. $text = '<b>&copy; 2005-2007, Cake Software Foundation, Inc.</b><br />written by Alexander Wegener';
  470. $result = $this->Text->truncate($text, 31, [
  471. 'html' => true,
  472. 'exact' => false,
  473. ]);
  474. $expected = '<b>&copy; 2005-2007, Cake Software...</b>';
  475. $this->assertEquals($expected, $result);
  476. $result = $this->Text->truncate($text, 31, [
  477. 'html' => true,
  478. 'exact' => true,
  479. ]);
  480. $expected = '<b>&copy; 2005-2007, Cake Software F...</b>';
  481. $this->assertEquals($expected, $result);
  482. }
  483. /**
  484. * testTail method
  485. *
  486. * @return void
  487. */
  488. public function testTail()
  489. {
  490. $text1 = 'The quick brown fox jumps over the lazy dog';
  491. $text2 = 'Heiz&ouml;lr&uuml;cksto&szlig;abd&auml;mpfung';
  492. $text3 = 'El moño está en el lugar correcto. Eso fue lo que dijo la niña, ¿habrá dicho la verdad?';
  493. $text4 = 'Vive la R' . chr(195) . chr(169) . 'publique de France';
  494. $text5 = 'НОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь';
  495. $result = $this->Text->tail($text1, 13);
  496. $this->assertEquals('...e lazy dog', $result);
  497. $result = $this->Text->tail($text1, 13, ['exact' => false]);
  498. $this->assertEquals('...lazy dog', $result);
  499. $result = $this->Text->tail($text1, 100);
  500. $this->assertEquals('The quick brown fox jumps over the lazy dog', $result);
  501. $result = $this->Text->tail($text2, 10);
  502. $this->assertEquals('...;mpfung', $result);
  503. $result = $this->Text->tail($text2, 10, ['exact' => false]);
  504. $this->assertEquals('...', $result);
  505. $result = $this->Text->tail($text3, 255);
  506. $this->assertEquals($text3, $result);
  507. $result = $this->Text->tail($text3, 21);
  508. $this->assertEquals('...á dicho la verdad?', $result);
  509. $result = $this->Text->tail($text4, 25);
  510. $this->assertEquals('...a R' . chr(195) . chr(169) . 'publique de France', $result);
  511. $result = $this->Text->tail($text5, 10);
  512. $this->assertEquals('...цчшщъыь', $result);
  513. $result = $this->Text->tail($text5, 6, ['ellipsis' => '']);
  514. $this->assertEquals('чшщъыь', $result);
  515. }
  516. /**
  517. * testHighlight method
  518. *
  519. * @return void
  520. */
  521. public function testHighlight()
  522. {
  523. $text = 'This is a test text';
  524. $phrases = ['This', 'text'];
  525. $result = $this->Text->highlight($text, $phrases, ['format' => '<b>\1</b>']);
  526. $expected = '<b>This</b> is a test <b>text</b>';
  527. $this->assertEquals($expected, $result);
  528. $phrases = ['is', 'text'];
  529. $result = $this->Text->highlight($text, $phrases, ['format' => '<b>\1</b>', 'regex' => "|\b%s\b|iu"]);
  530. $expected = 'This <b>is</b> a test <b>text</b>';
  531. $this->assertEquals($expected, $result);
  532. $text = 'This is a test text';
  533. $phrases = null;
  534. $result = $this->Text->highlight($text, $phrases, ['format' => '<b>\1</b>']);
  535. $this->assertEquals($text, $result);
  536. $text = 'This is a (test) text';
  537. $phrases = '(test';
  538. $result = $this->Text->highlight($text, $phrases, ['format' => '<b>\1</b>']);
  539. $this->assertEquals('This is a <b>(test</b>) text', $result);
  540. $text = 'Ich saß in einem Café am Übergang';
  541. $expected = 'Ich <b>saß</b> in einem <b>Café</b> am <b>Übergang</b>';
  542. $phrases = ['saß', 'café', 'übergang'];
  543. $result = $this->Text->highlight($text, $phrases, ['format' => '<b>\1</b>']);
  544. $this->assertEquals($expected, $result);
  545. }
  546. /**
  547. * testHighlightHtml method
  548. *
  549. * @return void
  550. */
  551. public function testHighlightHtml()
  552. {
  553. $text1 = '<p>strongbow isn&rsquo;t real cider</p>';
  554. $text2 = '<p>strongbow <strong>isn&rsquo;t</strong> real cider</p>';
  555. $text3 = '<img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
  556. $text4 = 'What a strong mouse: <img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
  557. $options = ['format' => '<b>\1</b>', 'html' => true];
  558. $expected = '<p><b>strong</b>bow isn&rsquo;t real cider</p>';
  559. $this->assertEquals($expected, $this->Text->highlight($text1, 'strong', $options));
  560. $expected = '<p><b>strong</b>bow <strong>isn&rsquo;t</strong> real cider</p>';
  561. $this->assertEquals($expected, $this->Text->highlight($text2, 'strong', $options));
  562. $this->assertEquals($text3, $this->Text->highlight($text3, 'strong', $options));
  563. $this->assertEquals($text3, $this->Text->highlight($text3, ['strong', 'what'], $options));
  564. $expected = '<b>What</b> a <b>strong</b> mouse: <img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
  565. $this->assertEquals($expected, $this->Text->highlight($text4, ['strong', 'what'], $options));
  566. }
  567. /**
  568. * testHighlightMulti method
  569. *
  570. * @return void
  571. */
  572. public function testHighlightMulti()
  573. {
  574. $text = 'This is a test text';
  575. $phrases = ['This', 'text'];
  576. $result = $this->Text->highlight($text, $phrases, ['format' => ['<b>\1</b>', '<em>\1</em>']]);
  577. $expected = '<b>This</b> is a test <em>text</em>';
  578. $this->assertEquals($expected, $result);
  579. }
  580. /**
  581. * testStripLinks method
  582. *
  583. * @return void
  584. */
  585. public function testStripLinks()
  586. {
  587. $text = 'This is a test text';
  588. $expected = 'This is a test text';
  589. $result = $this->Text->stripLinks($text);
  590. $this->assertEquals($expected, $result);
  591. $text = 'This is a <a href="#">test</a> text';
  592. $expected = 'This is a test text';
  593. $result = $this->Text->stripLinks($text);
  594. $this->assertEquals($expected, $result);
  595. $text = 'This <strong>is</strong> a <a href="#">test</a> <a href="#">text</a>';
  596. $expected = 'This <strong>is</strong> a test text';
  597. $result = $this->Text->stripLinks($text);
  598. $this->assertEquals($expected, $result);
  599. $text = 'This <strong>is</strong> a <a href="#">test</a> and <abbr>some</abbr> other <a href="#">text</a>';
  600. $expected = 'This <strong>is</strong> a test and <abbr>some</abbr> other text';
  601. $result = $this->Text->stripLinks($text);
  602. $this->assertEquals($expected, $result);
  603. }
  604. /**
  605. * testHighlightCaseInsensitivity method
  606. *
  607. * @return void
  608. */
  609. public function testHighlightCaseInsensitivity()
  610. {
  611. $text = 'This is a Test text';
  612. $expected = 'This is a <b>Test</b> text';
  613. $result = $this->Text->highlight($text, 'test', ['format' => '<b>\1</b>']);
  614. $this->assertEquals($expected, $result);
  615. $result = $this->Text->highlight($text, ['test'], ['format' => '<b>\1</b>']);
  616. $this->assertEquals($expected, $result);
  617. }
  618. /**
  619. * testExcerpt method
  620. *
  621. * @return void
  622. */
  623. public function testExcerpt()
  624. {
  625. $text = 'This is a phrase with test text to play with';
  626. $expected = '...ase with test text to ...';
  627. $result = $this->Text->excerpt($text, 'test', 9, '...');
  628. $this->assertEquals($expected, $result);
  629. $expected = 'This is a...';
  630. $result = $this->Text->excerpt($text, 'not_found', 9, '...');
  631. $this->assertEquals($expected, $result);
  632. $expected = 'This is a phras...';
  633. $result = $this->Text->excerpt($text, null, 9, '...');
  634. $this->assertEquals($expected, $result);
  635. $expected = $text;
  636. $result = $this->Text->excerpt($text, null, 200, '...');
  637. $this->assertEquals($expected, $result);
  638. $expected = '...a phrase w...';
  639. $result = $this->Text->excerpt($text, 'phrase', 2, '...');
  640. $this->assertEquals($expected, $result);
  641. $phrase = 'This is a phrase with test text';
  642. $expected = $text;
  643. $result = $this->Text->excerpt($text, $phrase, 13, '...');
  644. $this->assertEquals($expected, $result);
  645. $text = 'aaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaa';
  646. $phrase = 'bbbbbbbb';
  647. $result = $this->Text->excerpt($text, $phrase, 10);
  648. $expected = '...aaaaaaaaaabbbbbbbbaaaaaaaaaa...';
  649. $this->assertEquals($expected, $result);
  650. }
  651. /**
  652. * testExcerptCaseInsensitivity method
  653. *
  654. * @return void
  655. */
  656. public function testExcerptCaseInsensitivity()
  657. {
  658. $text = 'This is a phrase with test text to play with';
  659. $expected = '...ase with test text to ...';
  660. $result = $this->Text->excerpt($text, 'TEST', 9, '...');
  661. $this->assertEquals($expected, $result);
  662. $expected = 'This is a...';
  663. $result = $this->Text->excerpt($text, 'NOT_FOUND', 9, '...');
  664. $this->assertEquals($expected, $result);
  665. }
  666. /**
  667. * testListGeneration method
  668. *
  669. * @return void
  670. */
  671. public function testListGeneration()
  672. {
  673. $result = $this->Text->toList([]);
  674. $this->assertEquals('', $result);
  675. $result = $this->Text->toList(['One']);
  676. $this->assertEquals('One', $result);
  677. $result = $this->Text->toList(['Larry', 'Curly', 'Moe']);
  678. $this->assertEquals('Larry, Curly and Moe', $result);
  679. $result = $this->Text->toList(['Dusty', 'Lucky', 'Ned'], 'y');
  680. $this->assertEquals('Dusty, Lucky y Ned', $result);
  681. $result = $this->Text->toList([1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'], 'y');
  682. $this->assertEquals('Dusty, Lucky y Ned', $result);
  683. $result = $this->Text->toList([1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'], 'and', ' + ');
  684. $this->assertEquals('Dusty + Lucky and Ned', $result);
  685. $result = $this->Text->toList(['name1' => 'Dusty', 'name2' => 'Lucky']);
  686. $this->assertEquals('Dusty and Lucky', $result);
  687. $result = $this->Text->toList(['test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon']);
  688. $this->assertEquals('banana, apple and lemon', $result);
  689. }
  690. /**
  691. * testUtf8 method
  692. *
  693. * @return void
  694. */
  695. public function testUtf8()
  696. {
  697. $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
  698. $result = String::utf8($string);
  699. $expected = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
  700. 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
  701. 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
  702. 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126];
  703. $this->assertEquals($expected, $result);
  704. $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ';
  705. $result = String::utf8($string);
  706. $expected = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
  707. 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200];
  708. $this->assertEquals($expected, $result);
  709. $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ';
  710. $result = String::utf8($string);
  711. $expected = [201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
  712. 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
  713. 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263,
  714. 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  715. 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300];
  716. $this->assertEquals($expected, $result);
  717. $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ';
  718. $result = String::utf8($string);
  719. $expected = [301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
  720. 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
  721. 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
  722. 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
  723. 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400];
  724. $this->assertEquals($expected, $result);
  725. $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ';
  726. $result = String::utf8($string);
  727. $expected = [401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421,
  728. 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442,
  729. 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463,
  730. 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484,
  731. 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500];
  732. $this->assertEquals($expected, $result);
  733. $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ';
  734. $result = String::utf8($string);
  735. $expected = [601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621,
  736. 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642,
  737. 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663,
  738. 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684,
  739. 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700];
  740. $this->assertEquals($expected, $result);
  741. $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ';
  742. $result = String::utf8($string);
  743. $expected = [1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041,
  744. 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051];
  745. $this->assertEquals($expected, $result);
  746. $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь';
  747. $result = String::utf8($string);
  748. $expected = [1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069,
  749. 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087,
  750. 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100];
  751. $this->assertEquals($expected, $result);
  752. $string = 'չպջռսվտ';
  753. $result = String::utf8($string);
  754. $expected = [1401, 1402, 1403, 1404, 1405, 1406, 1407];
  755. $this->assertEquals($expected, $result);
  756. $string = 'فقكلمنهوىيًٌٍَُ';
  757. $result = String::utf8($string);
  758. $expected = [1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615];
  759. $this->assertEquals($expected, $result);
  760. $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞';
  761. $result = String::utf8($string);
  762. $expected = [10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044,
  763. 10045, 10046, 10047, 10048, 10049, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057,
  764. 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070,
  765. 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078];
  766. $this->assertEquals($expected, $result);
  767. $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠';
  768. $result = String::utf8($string);
  769. $expected = [11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919,
  770. 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11931, 11932, 11933, 11934, 11935, 11936,
  771. 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952,
  772. 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, 11966, 11967, 11968,
  773. 11969, 11970, 11971, 11972, 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984,
  774. 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000];
  775. $this->assertEquals($expected, $result);
  776. $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿';
  777. $result = String::utf8($string);
  778. $expected = [12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116,
  779. 12117, 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132,
  780. 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148,
  781. 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159];
  782. $this->assertEquals($expected, $result);
  783. $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄';
  784. $result = String::utf8($string);
  785. $expected = [45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616,
  786. 45617, 45618, 45619, 45620, 45621, 45622, 45623, 45624, 45625, 45626, 45627, 45628, 45629, 45630, 45631, 45632,
  787. 45633, 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, 45644, 45645, 45646, 45647, 45648,
  788. 45649, 45650, 45651, 45652, 45653, 45654, 45655, 45656, 45657, 45658, 45659, 45660, 45661, 45662, 45663, 45664,
  789. 45665, 45666, 45667, 45668, 45669, 45670, 45671, 45672, 45673, 45674, 45675, 45676, 45677, 45678, 45679, 45680,
  790. 45681, 45682, 45683, 45684, 45685, 45686, 45687, 45688, 45689, 45690, 45691, 45692, 45693, 45694, 45695, 45696,
  791. 45697, 45698, 45699, 45700];
  792. $this->assertEquals($expected, $result);
  793. $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ';
  794. $result = String::utf8($string);
  795. $expected = [65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151,
  796. 65152, 65153, 65154, 65155, 65156, 65157, 65158, 65159, 65160, 65161, 65162, 65163, 65164, 65165, 65166, 65167,
  797. 65168, 65169, 65170, 65171, 65172, 65173, 65174, 65175, 65176, 65177, 65178, 65179, 65180, 65181, 65182, 65183,
  798. 65184, 65185, 65186, 65187, 65188, 65189, 65190, 65191, 65192, 65193, 65194, 65195, 65196, 65197, 65198, 65199,
  799. 65200];
  800. $this->assertEquals($expected, $result);
  801. $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ';
  802. $result = String::utf8($string);
  803. $expected = [65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216,
  804. 65217, 65218, 65219, 65220, 65221, 65222, 65223, 65224, 65225, 65226, 65227, 65228, 65229, 65230, 65231, 65232,
  805. 65233, 65234, 65235, 65236, 65237, 65238, 65239, 65240, 65241, 65242, 65243, 65244, 65245, 65246, 65247, 65248,
  806. 65249, 65250, 65251, 65252, 65253, 65254, 65255, 65256, 65257, 65258, 65259, 65260, 65261, 65262, 65263, 65264,
  807. 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276];
  808. $this->assertEquals($expected, $result);
  809. $string = 'abcdefghijklmnopqrstuvwxyz';
  810. $result = String::utf8($string);
  811. $expected = [65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360,
  812. 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370];
  813. $this->assertEquals($expected, $result);
  814. $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク';
  815. $result = String::utf8($string);
  816. $expected = [65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392,
  817. 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400];
  818. $this->assertEquals($expected, $result);
  819. $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙';
  820. $result = String::utf8($string);
  821. $expected = [65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416,
  822. 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432,
  823. 65433, 65434, 65435, 65436, 65437, 65438];
  824. $this->assertEquals($expected, $result);
  825. $string = 'Ĥēĺļŏ, Ŵőřļď!';
  826. $result = String::utf8($string);
  827. $expected = [292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33];
  828. $this->assertEquals($expected, $result);
  829. $string = 'Hello, World!';
  830. $result = String::utf8($string);
  831. $expected = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33];
  832. $this->assertEquals($expected, $result);
  833. $string = '¨';
  834. $result = String::utf8($string);
  835. $expected = [168];
  836. $this->assertEquals($expected, $result);
  837. $string = '¿';
  838. $result = String::utf8($string);
  839. $expected = [191];
  840. $this->assertEquals($expected, $result);
  841. $string = 'čini';
  842. $result = String::utf8($string);
  843. $expected = [269, 105, 110, 105];
  844. $this->assertEquals($expected, $result);
  845. $string = 'moći';
  846. $result = String::utf8($string);
  847. $expected = [109, 111, 263, 105];
  848. $this->assertEquals($expected, $result);
  849. $string = 'državni';
  850. $result = String::utf8($string);
  851. $expected = [100, 114, 382, 97, 118, 110, 105];
  852. $this->assertEquals($expected, $result);
  853. $string = '把百度设为首页';
  854. $result = String::utf8($string);
  855. $expected = [25226, 30334, 24230, 35774, 20026, 39318, 39029];
  856. $this->assertEquals($expected, $result);
  857. $string = '一二三周永龍';
  858. $result = String::utf8($string);
  859. $expected = [19968, 20108, 19977, 21608, 27704, 40845];
  860. $this->assertEquals($expected, $result);
  861. $string = 'ԀԂԄԆԈԊԌԎԐԒ';
  862. $result = String::utf8($string);
  863. $expected = [1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298];
  864. $this->assertEquals($expected, $result);
  865. $string = 'ԁԃԅԇԉԋԍԏԐԒ';
  866. $result = String::utf8($string);
  867. $expected = [1281, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1296, 1298];
  868. $this->assertEquals($expected, $result);
  869. $string = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև';
  870. $result = String::utf8($string);
  871. $expected = [1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346,
  872. 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364,
  873. 1365, 1366, 1415];
  874. $this->assertEquals($expected, $result);
  875. $string = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև';
  876. $result = String::utf8($string);
  877. $expected = [1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394,
  878. 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412,
  879. 1413, 1414, 1415];
  880. $this->assertEquals($expected, $result);
  881. $string = 'ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ';
  882. $result = String::utf8($string);
  883. $expected = [4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273,
  884. 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291,
  885. 4292, 4293];
  886. $this->assertEquals($expected, $result);
  887. $string = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ';
  888. $result = String::utf8($string);
  889. $expected = [7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714,
  890. 7716, 7718, 7720, 7722, 7724, 7726, 7728, 7730, 7732, 7734, 7736, 7738, 7740, 7742, 7744, 7746, 7748, 7750,
  891. 7752, 7754, 7756, 7758, 7760, 7762, 7764, 7766, 7768, 7770, 7772, 7774, 7776, 7778, 7780, 7782, 7784, 7786,
  892. 7788, 7790, 7792, 7794, 7796, 7798, 7800, 7802, 7804, 7806, 7808, 7810, 7812, 7814, 7816, 7818, 7820, 7822,
  893. 7824, 7826, 7828, 7830, 7831, 7832, 7833, 7834, 7840, 7842, 7844, 7846, 7848, 7850, 7852, 7854, 7856,
  894. 7858, 7860, 7862, 7864, 7866, 7868, 7870, 7872, 7874, 7876, 7878, 7880, 7882, 7884, 7886, 7888, 7890, 7892,
  895. 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928];
  896. $this->assertEquals($expected, $result);
  897. $string = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ';
  898. $result = String::utf8($string);
  899. $expected = [7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715,
  900. 7717, 7719, 7721, 7723, 7725, 7727, 7729, 7731, 7733, 7735, 7737, 7739, 7741, 7743, 7745, 7747, 7749, 7751,
  901. 7753, 7755, 7757, 7759, 7761, 7763, 7765, 7767, 7769, 7771, 7773, 7775, 7777, 7779, 7781, 7783, 7785, 7787,
  902. 7789, 7791, 7793, 7795, 7797, 7799, 7801, 7803, 7805, 7807, 7809, 7811, 7813, 7815, 7817, 7819, 7821, 7823,
  903. 7825, 7827, 7829, 7830, 7831, 7832, 7833, 7834, 7841, 7843, 7845, 7847, 7849, 7851, 7853, 7855, 7857, 7859,
  904. 7861, 7863, 7865, 7867, 7869, 7871, 7873, 7875, 7877, 7879, 7881, 7883, 7885, 7887, 7889, 7891, 7893, 7895,
  905. 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915, 7917, 7919, 7921, 7923, 7925, 7927, 7929];
  906. $this->assertEquals($expected, $result);
  907. $string = 'ΩKÅℲ';
  908. $result = String::utf8($string);
  909. $expected = [8486, 8490, 8491, 8498];
  910. $this->assertEquals($expected, $result);
  911. $string = 'ωkåⅎ';
  912. $result = String::utf8($string);
  913. $expected = [969, 107, 229, 8526];
  914. $this->assertEquals($expected, $result);
  915. $string = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ';
  916. $result = String::utf8($string);
  917. $expected = [8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8579];
  918. $this->assertEquals($expected, $result);
  919. $string = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ';
  920. $result = String::utf8($string);
  921. $expected = [8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, 8575, 8580];
  922. $this->assertEquals($expected, $result);
  923. $string = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ';
  924. $result = String::utf8($string);
  925. $expected = [9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414,
  926. 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423];
  927. $this->assertEquals($expected, $result);
  928. $string = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ';
  929. $result = String::utf8($string);
  930. $expected = [9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441,
  931. 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449];
  932. $this->assertEquals($expected, $result);
  933. $string = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ';
  934. $result = String::utf8($string);
  935. $expected = [11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278,
  936. 11279, 11280, 11281, 11282, 11283, 11284, 11285, 11286, 11287, 11288, 11289, 11290, 11291, 11292, 11293,
  937. 11294, 11295, 11296, 11297, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11305, 11306, 11307, 11308,
  938. 11309, 11310];
  939. $this->assertEquals($expected, $result);
  940. $string = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ';
  941. $result = String::utf8($string);
  942. $expected = [11312, 11313, 11314, 11315, 11316, 11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327,
  943. 11328, 11329, 11330, 11331, 11332, 11333, 11334, 11335, 11336, 11337, 11338, 11339, 11340, 11341, 11342, 11343,
  944. 11344, 11345, 11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358];
  945. $this->assertEquals($expected, $result);
  946. $string = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ';
  947. $result = String::utf8($string);
  948. $expected = [11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, 11410, 11412, 11414, 11416, 11418, 11420,
  949. 11422, 11424, 11426, 11428, 11430, 11432, 11434, 11436, 11438, 11440, 11442, 11444, 11446, 11448, 11450,
  950. 11452, 11454, 11456, 11458, 11460, 11462, 11464, 11466, 11468, 11470, 11472, 11474, 11476, 11478, 11480,
  951. 11482, 11484, 11486, 11488, 11490];
  952. $this->assertEquals($expected, $result);
  953. $string = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ';
  954. $result = String::utf8($string);
  955. $expected = [11393, 11395, 11397, 11399, 11401, 11403, 11405, 11407, 11409, 11411, 11413, 11415, 11417, 11419, 11421, 11423,
  956. 11425, 11427, 11429, 11431, 11433, 11435, 11437, 11439, 11441, 11443, 11445, 11447, 11449, 11451, 11453, 11455,
  957. 11457, 11459, 11461, 11463, 11465, 11467, 11469, 11471, 11473, 11475, 11477, 11479, 11481, 11483, 11485, 11487,
  958. 11489, 11491];
  959. $this->assertEquals($expected, $result);
  960. $string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
  961. $result = String::utf8($string);
  962. $expected = [64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279];
  963. $this->assertEquals($expected, $result);
  964. }
  965. /**
  966. * testAscii method
  967. *
  968. * @return void
  969. */
  970. public function testAscii()
  971. {
  972. $input = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
  973. 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
  974. 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
  975. 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126];
  976. $result = String::ascii($input);
  977. $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
  978. $this->assertEquals($expected, $result);
  979. $input = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
  980. 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200];
  981. $result = String::ascii($input);
  982. $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ';
  983. $this->assertEquals($expected, $result);
  984. $input = [201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
  985. 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
  986. 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263,
  987. 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  988. 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300];
  989. $result = String::ascii($input);
  990. $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ';
  991. $this->assertEquals($expected, $result);
  992. $input = [301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
  993. 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
  994. 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
  995. 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
  996. 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400];
  997. $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ';
  998. $result = String::ascii($input);
  999. $this->assertEquals($expected, $result);
  1000. $input = [401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421,
  1001. 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442,
  1002. 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463,
  1003. 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484,
  1004. 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500];
  1005. $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ';
  1006. $result = String::ascii($input);
  1007. $this->assertEquals($expected, $result);
  1008. $input = [601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621,
  1009. 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642,
  1010. 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663,
  1011. 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684,
  1012. 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700];
  1013. $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ';
  1014. $result = String::ascii($input);
  1015. $this->assertEquals($expected, $result);
  1016. $input = [1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041,
  1017. 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051];
  1018. $expected = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ';
  1019. $result = String::ascii($input);
  1020. $this->assertEquals($expected, $result);
  1021. $input = [1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069,
  1022. 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087,
  1023. 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100];
  1024. $expected = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь';
  1025. $result = String::ascii($input);
  1026. $this->assertEquals($expected, $result);
  1027. $input = [1401, 1402, 1403, 1404, 1405, 1406, 1407];
  1028. $expected = 'չպջռսվտ';
  1029. $result = String::ascii($input);
  1030. $this->assertEquals($expected, $result);
  1031. $input = [1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615];
  1032. $expected = 'فقكلمنهوىيًٌٍَُ';
  1033. $result = String::ascii($input);
  1034. $this->assertEquals($expected, $result);
  1035. $input = [10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044,
  1036. 10045, 10046, 10047, 10048, 10049, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057,
  1037. 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070,
  1038. 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078];
  1039. $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞';
  1040. $result = String::ascii($input);
  1041. $this->assertEquals($expected, $result);
  1042. $input = [11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919,
  1043. 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11931, 11932, 11933, 11934, 11935, 11936,
  1044. 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952,
  1045. 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, 11966, 11967, 11968,
  1046. 11969, 11970, 11971, 11972, 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984,
  1047. 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000];
  1048. $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠';
  1049. $result = String::ascii($input);
  1050. $this->assertEquals($expected, $result);
  1051. $input = [12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116,
  1052. 12117, 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132,
  1053. 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148,
  1054. 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159];
  1055. $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿';
  1056. $result = String::ascii($input);
  1057. $this->assertEquals($expected, $result);
  1058. $input = [45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616,
  1059. 45617, 45618, 45619, 45620, 45621, 45622, 45623, 45624, 45625, 45626, 45627, 45628, 45629, 45630, 45631, 45632,
  1060. 45633, 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, 45644, 45645, 45646, 45647, 45648,
  1061. 45649, 45650, 45651, 45652, 45653, 45654, 45655, 45656, 45657, 45658, 45659, 45660, 45661, 45662, 45663, 45664,
  1062. 45665, 45666, 45667, 45668, 45669, 45670, 45671, 45672, 45673, 45674, 45675, 45676, 45677, 45678, 45679, 45680,
  1063. 45681, 45682, 45683, 45684, 45685, 45686, 45687, 45688, 45689, 45690, 45691, 45692, 45693, 45694, 45695, 45696,
  1064. 45697, 45698, 45699, 45700];
  1065. $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄';
  1066. $result = String::ascii($input);
  1067. $this->assertEquals($expected, $result);
  1068. $input = [65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151,
  1069. 65152, 65153, 65154, 65155, 65156, 65157, 65158, 65159, 65160, 65161, 65162, 65163, 65164, 65165, 65166, 65167,
  1070. 65168, 65169, 65170, 65171, 65172, 65173, 65174, 65175, 65176, 65177, 65178, 65179, 65180, 65181, 65182, 65183,
  1071. 65184, 65185, 65186, 65187, 65188, 65189, 65190, 65191, 65192, 65193, 65194, 65195, 65196, 65197, 65198, 65199,
  1072. 65200];
  1073. $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ';
  1074. $result = String::ascii($input);
  1075. $this->assertEquals($expected, $result);
  1076. $input = [65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216,
  1077. 65217, 65218, 65219, 65220, 65221, 65222, 65223, 65224, 65225, 65226, 65227, 65228, 65229, 65230, 65231, 65232,
  1078. 65233, 65234, 65235, 65236, 65237, 65238, 65239, 65240, 65241, 65242, 65243, 65244, 65245, 65246, 65247, 65248,
  1079. 65249, 65250, 65251, 65252, 65253, 65254, 65255, 65256, 65257, 65258, 65259, 65260, 65261, 65262, 65263, 65264,
  1080. 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276];
  1081. $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ';
  1082. $result = String::ascii($input);
  1083. $this->assertEquals($expected, $result);
  1084. $input = [65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360,
  1085. 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370];
  1086. $expected = 'abcdefghijklmnopqrstuvwxyz';
  1087. $result = String::ascii($input);
  1088. $this->assertEquals($expected, $result);
  1089. $input = [65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392,
  1090. 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400];
  1091. $expected = '。「」、・ヲァィゥェォャュョッーアイウエオカキク';
  1092. $result = String::ascii($input);
  1093. $this->assertEquals($expected, $result);
  1094. $input = [65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416,
  1095. 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432,
  1096. 65433, 65434, 65435, 65436, 65437, 65438];
  1097. $expected = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙';
  1098. $result = String::ascii($input);
  1099. $this->assertEquals($expected, $result);
  1100. $input = [292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33];
  1101. $expected = 'Ĥēĺļŏ, Ŵőřļď!';
  1102. $result = String::ascii($input);
  1103. $this->assertEquals($expected, $result);
  1104. $input = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33];
  1105. $expected = 'Hello, World!';
  1106. $result = String::ascii($input);
  1107. $this->assertEquals($expected, $result);
  1108. $input = [168];
  1109. $expected = '¨';
  1110. $result = String::ascii($input);
  1111. $this->assertEquals($expected, $result);
  1112. $input = [191];
  1113. $expected = '¿';
  1114. $result = String::ascii($input);
  1115. $this->assertEquals($expected, $result);
  1116. $input = [269, 105, 110, 105];
  1117. $expected = 'čini';
  1118. $result = String::ascii($input);
  1119. $this->assertEquals($expected, $result);
  1120. $input = [109, 111, 263, 105];
  1121. $expected = 'moći';
  1122. $result = String::ascii($input);
  1123. $this->assertEquals($expected, $result);
  1124. $input = [100, 114, 382, 97, 118, 110, 105];
  1125. $expected = 'državni';
  1126. $result = String::ascii($input);
  1127. $this->assertEquals($expected, $result);
  1128. $input = [25226, 30334, 24230, 35774, 20026, 39318, 39029];
  1129. $expected = '把百度设为首页';
  1130. $result = String::ascii($input);
  1131. $this->assertEquals($expected, $result);
  1132. $input = [19968, 20108, 19977, 21608, 27704, 40845];
  1133. $expected = '一二三周永龍';
  1134. $result = String::ascii($input);
  1135. $this->assertEquals($expected, $result);
  1136. $input = [1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298];
  1137. $expected = 'ԀԂԄԆԈԊԌԎԐԒ';
  1138. $result = String::ascii($input);
  1139. $this->assertEquals($expected, $result);
  1140. $input = [1281, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1296, 1298];
  1141. $expected = 'ԁԃԅԇԉԋԍԏԐԒ';
  1142. $result = String::ascii($input);
  1143. $this->assertEquals($expected, $result);
  1144. $input = [1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347,
  1145. 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365,
  1146. 1366, 1415];
  1147. $result = String::ascii($input);
  1148. $expected = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև';
  1149. $this->assertEquals($expected, $result);
  1150. $input = [1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394,
  1151. 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412,
  1152. 1413, 1414, 1415];
  1153. $result = String::ascii($input);
  1154. $expected = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև';
  1155. $this->assertEquals($expected, $result);
  1156. $input = [4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 4274,
  1157. 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293];
  1158. $result = String::ascii($input);
  1159. $expected = 'ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ';
  1160. $this->assertEquals($expected, $result);
  1161. $input = [7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714,
  1162. 7716, 7718, 7720, 7722, 7724, 7726, 7728, 7730, 7732, 7734, 7736, 7738, 7740, 7742, 7744, 7746, 7748, 7750,
  1163. 7752, 7754, 7756, 7758, 7760, 7762, 7764, 7766, 7768, 7770, 7772, 7774, 7776, 7778, 7780, 7782, 7784, 7786,
  1164. 7788, 7790, 7792, 7794, 7796, 7798, 7800, 7802, 7804, 7806, 7808, 7810, 7812, 7814, 7816, 7818, 7820, 7822,
  1165. 7824, 7826, 7828, 7830, 7831, 7832, 7833, 7834, 7840, 7842, 7844, 7846, 7848, 7850, 7852, 7854, 7856,
  1166. 7858, 7860, 7862, 7864, 7866, 7868, 7870, 7872, 7874, 7876, 7878, 7880, 7882, 7884, 7886, 7888, 7890, 7892,
  1167. 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928];
  1168. $result = String::ascii($input);
  1169. $expected = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ';
  1170. $this->assertEquals($expected, $result);
  1171. $input = [7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715,
  1172. 7717, 7719, 7721, 7723, 7725, 7727, 7729, 7731, 7733, 7735, 7737, 7739, 7741, 7743, 7745, 7747, 7749, 7751,
  1173. 7753, 7755, 7757, 7759, 7761, 7763, 7765, 7767, 7769, 7771, 7773, 7775, 7777, 7779, 7781, 7783, 7785, 7787,
  1174. 7789, 7791, 7793, 7795, 7797, 7799, 7801, 7803, 7805, 7807, 7809, 7811, 7813, 7815, 7817, 7819, 7821, 7823,
  1175. 7825, 7827, 7829, 7830, 7831, 7832, 7833, 7834, 7841, 7843, 7845, 7847, 7849, 7851, 7853, 7855, 7857, 7859,
  1176. 7861, 7863, 7865, 7867, 7869, 7871, 7873, 7875, 7877, 7879, 7881, 7883, 7885, 7887, 7889, 7891, 7893, 7895,
  1177. 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915, 7917, 7919, 7921, 7923, 7925, 7927, 7929];
  1178. $result = String::ascii($input);
  1179. $expected = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ';
  1180. $this->assertEquals($expected, $result);
  1181. $input = [8486, 8490, 8491, 8498];
  1182. $result = String::ascii($input);
  1183. $expected = 'ΩKÅℲ';
  1184. $this->assertEquals($expected, $result);
  1185. $input = [969, 107, 229, 8526];
  1186. $result = String::ascii($input);
  1187. $expected = 'ωkåⅎ';
  1188. $this->assertEquals($expected, $result);
  1189. $input = [8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8579];
  1190. $result = String::ascii($input);
  1191. $expected = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ';
  1192. $this->assertEquals($expected, $result);
  1193. $input = [8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, 8575, 8580];
  1194. $result = String::ascii($input);
  1195. $expected = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ';
  1196. $this->assertEquals($expected, $result);
  1197. $input = [9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414,
  1198. 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423];
  1199. $result = String::ascii($input);
  1200. $expected = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ';
  1201. $this->assertEquals($expected, $result);
  1202. $input = [9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441,
  1203. 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449];
  1204. $result = String::ascii($input);
  1205. $expected = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ';
  1206. $this->assertEquals($expected, $result);
  1207. $input = [11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278, 11279,
  1208. 11280, 11281, 11282, 11283, 11284, 11285, 11286, 11287, 11288, 11289, 11290, 11291, 11292, 11293, 11294, 11295,
  1209. 11296, 11297, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11305, 11306, 11307, 11308, 11309, 11310];
  1210. $result = String::ascii($input);
  1211. $expected = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ';
  1212. $this->assertEquals($expected, $result);
  1213. $input = [11312, 11313, 11314, 11315, 11316, 11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327,
  1214. 11328, 11329, 11330, 11331, 11332, 11333, 11334, 11335, 11336, 11337, 11338, 11339, 11340, 11341, 11342, 11343,
  1215. 11344, 11345, 11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358];
  1216. $result = String::ascii($input);
  1217. $expected = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ';
  1218. $this->assertEquals($expected, $result);
  1219. $input = [11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, 11410, 11412, 11414, 11416, 11418, 11420,
  1220. 11422, 11424, 11426, 11428, 11430, 11432, 11434, 11436, 11438, 11440, 11442, 11444, 11446, 11448, 11450,
  1221. 11452, 11454, 11456, 11458, 11460, 11462, 11464, 11466, 11468, 11470, 11472, 11474, 11476, 11478, 11480,
  1222. 11482, 11484, 11486, 11488, 11490];
  1223. $result = String::ascii($input);
  1224. $expected = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ';
  1225. $this->assertEquals($expected, $result);
  1226. $input = [11393, 11395, 11397, 11399, 11401, 11403, 11405, 11407, 11409, 11411, 11413, 11415, 11417, 11419, 11421, 11423,
  1227. 11425, 11427, 11429, 11431, 11433, 11435, 11437, 11439, 11441, 11443, 11445, 11447, 11449, 11451, 11453, 11455,
  1228. 11457, 11459, 11461, 11463, 11465, 11467, 11469, 11471, 11473, 11475, 11477, 11479, 11481, 11483, 11485, 11487,
  1229. 11489, 11491];
  1230. $result = String::ascii($input);
  1231. $expected = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ';
  1232. $this->assertEquals($expected, $result);
  1233. $input = [64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279];
  1234. $result = String::ascii($input);
  1235. $expected = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
  1236. $this->assertEquals($expected, $result);
  1237. }
  1238. /**
  1239. * testparseFileSize
  1240. *
  1241. * @dataProvider filesizes
  1242. * @return void
  1243. */
  1244. public function testparseFileSize($params, $expected)
  1245. {
  1246. $result = String::parseFileSize($params['size'], $params['default']);
  1247. $this->assertEquals($expected, $result);
  1248. }
  1249. /**
  1250. * testparseFileSizeException
  1251. *
  1252. * @expectedException \InvalidArgumentException
  1253. * @return void
  1254. */
  1255. public function testparseFileSizeException()
  1256. {
  1257. String::parseFileSize('bogus', false);
  1258. }
  1259. /**
  1260. * filesizes dataprovider
  1261. *
  1262. * @return array
  1263. */
  1264. public function filesizes()
  1265. {
  1266. return [
  1267. [['size' => '512B', 'default' => false], 512],
  1268. [['size' => '1KB', 'default' => false], 1024],
  1269. [['size' => '1.5KB', 'default' => false], 1536],
  1270. [['size' => '1MB', 'default' => false], 1048576],
  1271. [['size' => '1mb', 'default' => false], 1048576],
  1272. [['size' => '1.5MB', 'default' => false], 1572864],
  1273. [['size' => '1GB', 'default' => false], 1073741824],
  1274. [['size' => '1.5GB', 'default' => false], 1610612736],
  1275. [['size' => '1K', 'default' => false], 1024],
  1276. [['size' => '1.5K', 'default' => false], 1536],
  1277. [['size' => '1M', 'default' => false], 1048576],
  1278. [['size' => '1m', 'default' => false], 1048576],
  1279. [['size' => '1.5M', 'default' => false], 1572864],
  1280. [['size' => '1G', 'default' => false], 1073741824],
  1281. [['size' => '1.5G', 'default' => false], 1610612736],
  1282. [['size' => '512', 'default' => 'Unknown type'], 512],
  1283. [['size' => '2VB', 'default' => 'Unknown type'], 'Unknown type']
  1284. ];
  1285. }
  1286. }