draft-josefsson-idn-test-vectors.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <?php
  2. require_once 'Net/IDNA2.php';
  3. // Test cases from https://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
  4. define('IDNA_ACE_PREFIX', 'xn--');
  5. class IDNATest extends PHPUnit_Framework_TestCase
  6. {
  7. public function setUp()
  8. {
  9. $this->idn = new Net_IDNA2();
  10. }
  11. public static function unichr($chr)
  12. {
  13. return mb_convert_encoding('&#' . intval($chr) . ';', 'UTF-8', 'HTML-ENTITIES');
  14. }
  15. private function hexarray2string($arr)
  16. {
  17. return implode('', array_map(array('self', 'unichr'), $arr));
  18. }
  19. public function testDecode1()
  20. {
  21. // Arabic (Egyptian)
  22. $expected = $this->hexarray2string(array(
  23. 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643,
  24. 0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A,
  25. 0x061F
  26. ));
  27. $result = $this->idn->decode(IDNA_ACE_PREFIX . "egbpdaj6bu4bxfgehfvwxn");
  28. $this->assertSame($expected, $result);
  29. }
  30. public function testDecode2()
  31. {
  32. // Chinese (simplified)
  33. $expected = $this->hexarray2string(array(
  34. 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D, 0x6587
  35. ));
  36. $result = $this->idn->decode(IDNA_ACE_PREFIX . "ihqwcrb4cv8a8dqg056pqjye");
  37. $this->assertSame($expected, $result);
  38. }
  39. public function testDecode3()
  40. {
  41. // Chinese (traditional)
  42. $expected = $this->hexarray2string(array(
  43. 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D, 0x6587
  44. ));
  45. $result = $this->idn->decode(IDNA_ACE_PREFIX . "ihqwctvzc91f659drss3x8bo0yb");
  46. $this->assertSame($expected, $result);
  47. }
  48. public function testDecode4()
  49. {
  50. // Czech
  51. $expected = $this->hexarray2string(array(
  52. 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073,
  53. 0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076,
  54. 0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079
  55. ));
  56. $result = $this->idn->decode(IDNA_ACE_PREFIX . "Proprostnemluvesky-uyb24dma41a");
  57. $this->assertSame($expected, $result);
  58. }
  59. public function testDecode5()
  60. {
  61. // Hebrew
  62. $expected = $this->hexarray2string(array(
  63. 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5,
  64. 0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9,
  65. 0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA
  66. ));
  67. $result = $this->idn->decode(IDNA_ACE_PREFIX . "4dbcagdahymbxekheh6e0a7fei0b");
  68. $this->assertSame($expected, $result);
  69. }
  70. public function testDecode6()
  71. {
  72. // Hindi (Devanagari)
  73. $expected = $this->hexarray2string(array(
  74. 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928,
  75. 0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902,
  76. 0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938,
  77. 0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902
  78. ));
  79. $result = $this->idn->decode(IDNA_ACE_PREFIX . "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd");
  80. $this->assertSame($expected, $result);
  81. }
  82. public function testDecode7()
  83. {
  84. // Japanese (kanji and hiragana)
  85. $expected = $this->hexarray2string(array(
  86. 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E,
  87. 0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044,
  88. 0x306E, 0x304B
  89. ));
  90. $result = $this->idn->decode(IDNA_ACE_PREFIX . "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa");
  91. $this->assertSame($expected, $result);
  92. }
  93. public function testDecode8()
  94. {
  95. // Russian (Cyrillic)
  96. $expected = $this->hexarray2string(array(
  97. 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435,
  98. 0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432,
  99. 0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443,
  100. 0x0441, 0x0441, 0x043A, 0x0438
  101. ));
  102. $result = $this->idn->decode(IDNA_ACE_PREFIX . "b1abfaaepdrnnbgefbadotcwatmq2g4l");
  103. $this->assertSame($expected, $result);
  104. }
  105. public function testDecode9()
  106. {
  107. // Spanish
  108. $expected = $this->hexarray2string(array(
  109. 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F,
  110. 0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069,
  111. 0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074,
  112. 0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065,
  113. 0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F, 0x006C
  114. ));
  115. $result = $this->idn->decode(IDNA_ACE_PREFIX . "PorqunopuedensimplementehablarenEspaol-fmd56a");
  116. $this->assertSame($expected, $result);
  117. }
  118. public function testDecode10()
  119. {
  120. // Vietnamese
  121. $expected = $this->hexarray2string(array(
  122. 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD,
  123. 0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3,
  124. 0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069,
  125. 0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074
  126. ));
  127. $result = $this->idn->decode(IDNA_ACE_PREFIX . "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g");
  128. $this->assertSame($expected, $result);
  129. }
  130. public function testDecode11()
  131. {
  132. // Japanese
  133. $expected = $this->hexarray2string(array(
  134. 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148, 0x751F
  135. ));
  136. $result = $this->idn->decode(IDNA_ACE_PREFIX . "3B-ww4c5e180e575a65lsy2b");
  137. $this->assertSame($expected, $result);
  138. }
  139. public function testDecode12()
  140. {
  141. // Japanese
  142. $expected = $this->hexarray2string(array(
  143. 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069,
  144. 0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052,
  145. 0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059, 0x0053
  146. ));
  147. $result = $this->idn->decode(IDNA_ACE_PREFIX . "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n");
  148. $this->assertSame($expected, $result);
  149. }
  150. public function testDecode13()
  151. {
  152. // Japanese
  153. $expected = $this->hexarray2string(array(
  154. 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E,
  155. 0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061,
  156. 0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834,
  157. 0x6240
  158. ));
  159. $result = $this->idn->decode(IDNA_ACE_PREFIX . "Hello-Another-Way--fc4qua05auwb3674vfr0b");
  160. $this->assertSame($expected, $result);
  161. }
  162. public function testDecode14()
  163. {
  164. // Japanese
  165. $expected = $this->hexarray2string(array(
  166. 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B, 0x0032
  167. ));
  168. $result = $this->idn->decode(IDNA_ACE_PREFIX . "2-u9tlzr9756bt3uc0v");
  169. $this->assertSame($expected, $result);
  170. }
  171. public function testDecode15()
  172. {
  173. // Japanese
  174. $expected = $this->hexarray2string(array(
  175. 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069,
  176. 0x3059, 0x308B, 0x0035, 0x79D2, 0x524D
  177. ));
  178. $result = $this->idn->decode(IDNA_ACE_PREFIX . "MajiKoi5-783gue6qz075azm5e");
  179. $this->assertSame($expected, $result);
  180. }
  181. public function testDecode16()
  182. {
  183. // Japanese
  184. $expected = $this->hexarray2string(array(
  185. 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3, 0x30D0
  186. ));
  187. $result = $this->idn->decode(IDNA_ACE_PREFIX . "de-jg4avhby1noc0d");
  188. $this->assertSame($expected, $result);
  189. }
  190. public function testDecode17()
  191. {
  192. // Japanese
  193. $expected = $this->hexarray2string(array(
  194. 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067
  195. ));
  196. $result = $this->idn->decode(IDNA_ACE_PREFIX . "d9juau41awczczp");
  197. $this->assertSame($expected, $result);
  198. }
  199. public function testDecode18()
  200. {
  201. // Greek
  202. $expected = $this->hexarray2string(array(
  203. 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac
  204. ));
  205. $result = $this->idn->decode(IDNA_ACE_PREFIX . "hxargifdar");
  206. $this->assertSame($expected, $result);
  207. }
  208. public function testDecode19()
  209. {
  210. // Maltese (Malti)
  211. $expected = $this->hexarray2string(array(
  212. 0x0062, 0x006f, 0x006e, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127,
  213. 0x0127, 0x0061
  214. ));
  215. $result = $this->idn->decode(IDNA_ACE_PREFIX . "bonusaa-5bb1da");
  216. $this->assertSame($expected, $result);
  217. }
  218. public function testDecode20()
  219. {
  220. // Russian (Cyrillic)
  221. $expected = $this->hexarray2string(array(
  222. 0x043f, 0x043e, 0x0447, 0x0435, 0x043c, 0x0443, 0x0436, 0x0435,
  223. 0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432,
  224. 0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443,
  225. 0x0441, 0x0441, 0x043a, 0x0438
  226. ));
  227. $result = $this->idn->decode(IDNA_ACE_PREFIX . "b1abfaaepdrnnbgefbadotcwatmq2g4l");
  228. $this->assertSame($expected, $result);
  229. }
  230. public function testEncode1()
  231. {
  232. // Arabic (Egyptian)
  233. $idna = $this->hexarray2string(array(
  234. 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643,
  235. 0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A,
  236. 0x061F
  237. ));
  238. $result = $this->idn->encode($idna);
  239. $this->assertSame(IDNA_ACE_PREFIX . "egbpdaj6bu4bxfgehfvwxn", $result);
  240. }
  241. public function testEncode2()
  242. {
  243. // Chinese (simplified)
  244. $idna = $this->hexarray2string(array(
  245. 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D, 0x6587
  246. ));
  247. $result = $this->idn->encode($idna);
  248. $this->assertSame(IDNA_ACE_PREFIX . "ihqwcrb4cv8a8dqg056pqjye", $result);
  249. }
  250. public function testEncode3()
  251. {
  252. // Chinese (traditional)
  253. $idna = $this->hexarray2string(array(
  254. 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D, 0x6587
  255. ));
  256. $result = $this->idn->encode($idna);
  257. $this->assertSame(IDNA_ACE_PREFIX . "ihqwctvzc91f659drss3x8bo0yb", $result);
  258. }
  259. public function testEncode4()
  260. {
  261. // Czech
  262. $idna = $this->hexarray2string(array(
  263. 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073,
  264. 0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076,
  265. 0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079
  266. ));
  267. $result = $this->idn->encode($idna);
  268. $this->assertSame(IDNA_ACE_PREFIX . "proprostnemluvesky-uyb24dma41a", $result);
  269. }
  270. public function testEncode5()
  271. {
  272. // Hebrew
  273. $idna = $this->hexarray2string(array(
  274. 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5,
  275. 0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9,
  276. 0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA
  277. ));
  278. $result = $this->idn->encode($idna);
  279. $this->assertSame(IDNA_ACE_PREFIX . "4dbcagdahymbxekheh6e0a7fei0b", $result);
  280. }
  281. public function testEncode6()
  282. {
  283. // Hindi (Devanagari)
  284. $idna = $this->hexarray2string(array(
  285. 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928,
  286. 0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902,
  287. 0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938,
  288. 0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902
  289. ));
  290. $result = $this->idn->encode($idna);
  291. $this->assertSame(IDNA_ACE_PREFIX . "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd", $result);
  292. }
  293. public function testEncode7()
  294. {
  295. // Japanese (kanji and hiragana)
  296. $idna = $this->hexarray2string(array(
  297. 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E,
  298. 0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044,
  299. 0x306E, 0x304B
  300. ));
  301. $result = $this->idn->encode($idna);
  302. $this->assertSame(IDNA_ACE_PREFIX . "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa", $result);
  303. }
  304. public function testEncode8()
  305. {
  306. // Russian (Cyrillic)
  307. $idna = $this->hexarray2string(array(
  308. 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435,
  309. 0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432,
  310. 0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443,
  311. 0x0441, 0x0441, 0x043A, 0x0438
  312. ));
  313. $result = $this->idn->encode($idna);
  314. $this->assertSame(IDNA_ACE_PREFIX . "b1abfaaepdrnnbgefbadotcwatmq2g4l", $result);
  315. }
  316. public function testEncode9()
  317. {
  318. // Spanish
  319. $idna = $this->hexarray2string(array(
  320. 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F,
  321. 0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069,
  322. 0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074,
  323. 0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065,
  324. 0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F, 0x006C
  325. ));
  326. $result = $this->idn->encode($idna);
  327. $this->assertSame(IDNA_ACE_PREFIX . "porqunopuedensimplementehablarenespaol-fmd56a", $result);
  328. }
  329. public function testEncode10()
  330. {
  331. // Vietnamese
  332. $idna = $this->hexarray2string(array(
  333. 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD,
  334. 0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3,
  335. 0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069,
  336. 0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074
  337. ));
  338. $result = $this->idn->encode($idna);
  339. $this->assertSame(IDNA_ACE_PREFIX . "tisaohkhngthchnitingvit-kjcr8268qyxafd2f1b9g", $result);
  340. }
  341. public function testEncode11()
  342. {
  343. // Japanese
  344. $idna = $this->hexarray2string(array(
  345. 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148, 0x751F
  346. ));
  347. $result = $this->idn->encode($idna);
  348. $this->assertSame(IDNA_ACE_PREFIX . "3b-ww4c5e180e575a65lsy2b", $result);
  349. }
  350. public function testEncode12()
  351. {
  352. // Japanese
  353. $idna = $this->hexarray2string(array(
  354. 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069,
  355. 0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052,
  356. 0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059, 0x0053
  357. ));
  358. $result = $this->idn->encode($idna);
  359. $this->assertSame(IDNA_ACE_PREFIX . "-with-super-monkeys-pc58ag80a8qai00g7n9n", $result);
  360. }
  361. public function testEncode13()
  362. {
  363. // Japanese
  364. $idna = $this->hexarray2string(array(
  365. 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E,
  366. 0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061,
  367. 0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834,
  368. 0x6240
  369. ));
  370. $result = $this->idn->encode($idna);
  371. $this->assertSame(IDNA_ACE_PREFIX . "hello-another-way--fc4qua05auwb3674vfr0b", $result);
  372. }
  373. public function testEncode14()
  374. {
  375. // Japanese
  376. $idna = $this->hexarray2string(array(
  377. 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B, 0x0032
  378. ));
  379. $result = $this->idn->encode($idna);
  380. $this->assertSame(IDNA_ACE_PREFIX . "2-u9tlzr9756bt3uc0v", $result);
  381. }
  382. public function testEncode15()
  383. {
  384. // Japanese
  385. $idna = $this->hexarray2string(array(
  386. 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069,
  387. 0x3059, 0x308B, 0x0035, 0x79D2, 0x524D
  388. ));
  389. $result = $this->idn->encode($idna);
  390. $this->assertSame(IDNA_ACE_PREFIX . "majikoi5-783gue6qz075azm5e", $result);
  391. }
  392. public function testEncode16()
  393. {
  394. // Japanese
  395. $idna = $this->hexarray2string(array(
  396. 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3, 0x30D0
  397. ));
  398. $result = $this->idn->encode($idna);
  399. $this->assertSame(IDNA_ACE_PREFIX . "de-jg4avhby1noc0d", $result);
  400. }
  401. public function testEncode17()
  402. {
  403. // Japanese
  404. $idna = $this->hexarray2string(array(
  405. 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067
  406. ));
  407. $result = $this->idn->encode($idna);
  408. $this->assertSame(IDNA_ACE_PREFIX . "d9juau41awczczp", $result);
  409. }
  410. public function testEncode18()
  411. {
  412. // Greek
  413. $idna = $this->hexarray2string(array(
  414. 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac
  415. ));
  416. $result = $this->idn->encode($idna);
  417. $this->assertSame(IDNA_ACE_PREFIX . "hxargifdar", $result);
  418. }
  419. public function testEncode19()
  420. {
  421. // Maltese (Malti)
  422. $idna = $this->hexarray2string(array(
  423. 0x0062, 0x006f, 0x006e, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127,
  424. 0x0127, 0x0061
  425. ));
  426. $result = $this->idn->encode($idna);
  427. $this->assertSame(IDNA_ACE_PREFIX . "bonusaa-5bb1da", $result);
  428. }
  429. public function testEncode20()
  430. {
  431. // Russian (Cyrillic)
  432. $idna = $this->hexarray2string(array(
  433. 0x043f, 0x043e, 0x0447, 0x0435, 0x043c, 0x0443, 0x0436, 0x0435,
  434. 0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432,
  435. 0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443,
  436. 0x0441, 0x0441, 0x043a, 0x0438
  437. ));
  438. $result = $this->idn->encode($idna);
  439. $this->assertSame(IDNA_ACE_PREFIX . "b1abfaaepdrnnbgefbadotcwatmq2g4l", $result);
  440. }
  441. }