StringTest.php 73 KB

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