StringTest.php 73 KB

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