"Hy laat my in groen weivelde rus. Hy bring my by waters waar daar vrede is.", 'albanian' => "Çdokush prej jush mund të kontribuojë vullnetarisht me dijen e tij për zgjerimin e mëtejshëm të kësaj enciklopedie të lirë.", 'alemannic' => "Das bedütet, dass a dem Projekt alli chöi teilnä, wo en alemannischi Dialektspilart beherrsche, wo da gredt wird.", 'amharic' => "ዳግማዊ ፡ ምኒልክ ፡ ንጉሠ ፡ ነገሥት ፡ ዘኢትዮጵያ ።", 'arabic' => "ما اسمك؟", 'armenian' => "Ընդհանուր տեղեկություններ, կառավարման համակարգ, ժողովրդագրություն և աշխարհագրական տվյալներ:", 'asturian' => "La ortografía nun ye fonolóxica sinon histórica, tando considerada como una de les llingües más abegoses d'aprender de les qu'usen esi alfabetu.", 'belarusian' => "Умоўным часам пачатку гісторыі сучаснай беларускай літаратурнай мовы лічыцца пачатак 19 стагоддзя.", 'bosnian' => "Engleski jezik je nastao iz jezika germanskih plemena koja su se u kasnom starom vijeku naselila na jugoistoku otoka Velike Britanije.", 'brazilian' => "O governo federal irá zerar o número de municípios sem bibliotecas este ano. De acordo com o Sistema Nacional de Bibliotecas Públicas, 661 municípios ainda não têm esses equipamentos. Se sua cidade não estiver nesta relação e não possuir biblioteca pública municipal, informe aqui. A cultura é um direito de todo o cidadão!", 'breton' => "Hon Tad, c'hwi hag a zo en Neñv, ra vo santelaet hoc'h ano. Ra zeuio ho Rouantelezh.", 'bulgarian' => "Глобалното затопляне ще освободи Северния ледовит океан от ледовете през лятото през следващите 20 години.", 'catalan' => "Els drets juridicolingüístics dels catalanoparlants són ben diferents segons l'indret geogràfic, podem parlar de catalanoparlants de primera i de segona.", 'croatian' => "Oče naš, koji jesi na nebesima, sveti se ime Tvoje. Dođi kraljevstvo Tvoje, budi volja Tvoja, kako na Nebu, tako i na Zemlji.", 'czech' => "V převážné většině mezinárodních škol je vyučovacím jazykem angličtina.", 'danish' => "Et ganske særligt kendetegn ved dansk er stød.", 'dari' => "جمعیت افغانستان حدود ۳۰ میلیون نفر برآورد میشود. براساس سرشماری مقدماتی کمیته ملی احصائیه کشور، جمعیت افغانستان در سال ۱۳۸۵، ۲۴ میلیون", 'dutch' => "De officiële taal, zoals die wordt onderwezen op scholen en gebruikt wordt door de autoriteiten, wordt Standaardnederlands genoemd.", 'english' => "Approximately 375 million people speak English as their first language.", 'esperanto' => "La vortprovizo de Esperanto devenas plejparte el la okcidenteŭropaj lingvoj, dum ĝia sintakso kaj morfologio montras ankaŭ slavlingvan influon.", 'estonian' => "Ta eelistab lubjarikast pinnast, kuid kasvab ka settelistel muldadel ja väheviljakal pinnasel, kus teisi puittaimi ei leidu.", 'basque' => "Euskaren gramatika zailtasun handikoa da, horrez gain, hizkuntza indoeuroparra ez izanik, eratze edo joskera bereziak ditu, beste hizkuntzetan aurkitu ez ditzakegunak.", 'finnish' => "Nominit taipuvat sijoissa eli sijamuodoissa yleensä sekä yksikössä että monikossa.", 'french' => "La majorité du fonds lexical français provient du latin (en tant que langue-mère) ou bien est construit à partir des racines gréco-latines.", 'frisian' => "Us Heit, dy't yn de himelen is jins namme wurde hillige. Jins keninkryk komme.", 'friulian' => "Mandi, jo mi clami Jacum! Vuê al è propite cjalt! O scugni propite lâ cumò, ariviodisi.", 'galician' => "Se borrarán todos los comentarios que, con criterio subjetivo como en toda web, se consideren inadecuados.", 'georgian' => "საკუთარ პერიოდში ბუგერო მსოფლიოს ერთ-ერთ უდიდეს მხატვრად იყო აღიარებული, თუმცა მე-20 საუკუნის დასაწყისში მას უკვე არაფრად აგდებდნენ, შესაძლოა მისი იმპრესიონისტთა მიმართ აგრესიულობის გამო. მიუხედავად ამისა, დღეს მას თაყვანისმცემლების ახალი დიდი ტალღა შეემატა - მისი ნამუშევრები მსოფლიოს ასზე მეტ უდიდეს მუზეუმშია გამოფენილი.", 'german' => "Durch ihre zentrale Lage in Europa wurde die deutsche Sprache über die Jahrhunderte durch andere Sprachen beeinflusst.", 'greek' => "Η ναυτική βιομηχανία αποτέλεσε ένα σημαντικό στοιχείο της Ελληνικής οικονομικής δραστηριότητας από τα αρχαία χρόνια.", 'hawaiian' => "A ma mua o ka hō'ea 'ana i Tahiti, ua ho'okele maila lākou mai Sāmoa a Tonga paha.", 'hebrew' => "שימו לב: אם עדיין לא נרשמתם, ייתכן כי חלק מהתכונות אינן זמינות לכם. במקרה זה רצוי ליצור חשבון חדש, פעולה האורכת מספר דקות בלבד. ראו איך ליצור חשבון חדש.", 'hindi' => "साइट का लिंक लगाने के लिए निम्नांकित फार्मेट में उपयुक्त कक्ष में/या नया कक्ष बना कर लिखें :", 'hungarian' => "A magyar nyelv az uráli nyelvcsalád tagja, a finnugor nyelvek közé tartozó ugor nyelvek egyike.", 'icelandic' => "Margir Íslendingar telja íslenskuna vera „upprunalegra“ mál en flest önnur og að hún hafi breyst minna.", 'indonesian' => "Selain itu, Baristand senantiasa meningkatkan kualitas personil dan berbagai fasilitas pendukung industri, serta fasilitas lainnya yaitu perpustakaan dengan buku-buku ilmiah, laporan hasil penelitian, dan majalah ilmiah.", 'irish' => "háinig críoch dheifnideach lena chuid scríbhneoireachta nuair a cuireadh i dteach na ngealt é agus síocóis dhúlagrach ag luí ar a intinn.", 'italian' => "Tuttavia l'assetto attuale della lingua è in sostanza quello del fiorentino trecentesco, ripulito dei tratti più marcatamente locali.", 'japanese' => "日本語(にほんご、にっぽんご)は、主として、日本で使用されてきた言語である。日本国は法令上、公用語を明記していないが、事実上の公用語となっており、学校教育の「国語」で教えられる。", 'korean' => "이 문서는 삭제되었습니다. 이 문서의 삭제/이동 기록은 다음과 같습니다.", 'latin' => "Architecti est scientia pluribus disciplinis et variis eruditionibus ornata, cuius iudicio probantur omnia quae ab ceteris artibus perficiuntur opera.", 'latvian' => "Tas visvairāk ir vērojams jaunu terminu darināšanā, kas bieži izsauc arī negatīvu reakciju.", 'lithuanian' => "Dabartinės literatūrinės kalbos pagrindas remiasi vakarų aukštaičių pietiečių (suvalkiečių) tarme, išlaikiusia senesnes fonetikos ir morfologijos lytis.", 'macedonian' => "Залагањето за создавање на македонски литературен јазик датира уште од почетокот на XIX век, со појавата на Просветителите.", 'malay' => "Suntingan yang tidak sesuai akan dikeluarkan segera, dan pesalah yang berulang boleh disekat daripada menyunting. Harap maklum.", 'manx' => "Haink ram cooney da aavioghey ny Gaelgey liorish yn obbyr recortyssagh jeant liorish aahirreyderyn 'sy 20oo eash.", 'marathi' => "समस्त विकिपीडिया वाचक आणि संपादकांना दीपावलीच्या हार्दीक शुभेच्छा !", 'middle_frisian' => "30 beest van en wief dat er gen schrift van is dy plæge hem Kom krod my ney de Verman ta.", 'mingo' => "Kakwékö nêkê ne'hu niyawë'ö, ne n-u'kaiwayeí ne' thusnye'ö N-awëníyu', ne' húkwa huwënitkëhtahkö haya'tatek, n- utukëstaniak, háwê,", 'nepali' => "तपाईंको/तिम्रो नाम के हो?", 'norwegian' => "Språksamfunn lånar ord frå meir prestisjefylte språksamfunn, via tospråklege talarar. Studium av lånordslag i norsk speglar dermed samfunnsmessige tilhøve i Europa opp gjennom hundreåra.", 'occitan' => "Ara s'estima que sus una populacion de 14 o 15 milions d'occitans, son entre 500 000 e 2 000 000 los que son capables de parlar l'occitan correntament, mas las ocasions de lo parlar dins la societat son raras.", 'pashto' => "د راجيت سيتارام پنډت په قول ميلنده پڼهو اصلي نسخه په زړه پښتو ليکل شويده - موړ کتاب چې د", 'persian' => "زبان فارسی (پارسی، دری، یا تاجیکی) زبانی است که در کشورهای ایران، افغانستان[۲]، تاجیکستان[۳] و", 'polish' => "Język polski wywodzi się z języka praindoeuropejskiego za pośrednictwem języka prasłowiańskiego.", 'portuguese' => "Assim como os outros idiomas, o português sofreu uma evolução histórica, sendo influenciado por vários idiomas e dialetos, até chegar ao estágio conhecido atualmente. Deve-se considerar, porém, que o português de hoje compreende vários dialetos e subdialetos, falares e subfalares, muitas vezes bastante distintos, além de dois padrões reconhecidos internacionalmente (português brasileiro e português europeu).", 'quechua_cusco' => "Simi yachaqkunaqa rimanakun, qhichwa simi hukllachu achkachu rimay. SIL International nisqa tantanakuy ninmi, 42 rimaymi, nispa.", 'romanian' => "Limba română este vorbită în toată lumea de aproximativ 26 de milioane de persoane.", 'rumantsch' => "Mintga idiom ha sviluppà sia atgna lingua da scrittira ch'è dentant savens era puspè in cumpromiss tranter ils differents dialects regiunals e locals.", 'russian' => "Русский язык — один из восточнославянских языков, один из крупнейших языков мира, в том числе самый распространённый из славянских языков и самый распространённый язык Европы, как географически, так и по числу носителей языка как родного (хотя также значительная и географически большая часть русского языкового ареала находится в Азии).", 'sanskrit' => "एयं भाषा न केवलं भारतस्य अपितु विश्वस्यप्राचीनतमा भाषा मन्यते। इयं भाषा एतावती समृद्घा अस्ति यत् प्राय: सर्वासु भारतीयभाषासु न्यूनाधिकरूपेण अस्या: शब्दा: प्रयुज्यन्ते. अत: भाषाविदां मते इयं सर्वासां भाषाणां जननी मन्यते। पुरा संस्कृतं लोकभाषा आसीत्। जना: संस्कृतं वदन्ति स्म॥ विश्वस्य आदिम: ग्रन्थ: ऋग्वेद: संस्कृतभाषायामेवास्ति। अन्ये च वेदा: यथा यजुर्वेद:, सामवेद:, अथर्ववेदश्च संस्कृतभाषायामेव सन्ति। आयुर्वेद धनुर्वेद गन्धर्ववेदार्थवेदाख्या: चत्वार: उपवेदा: अपि संस्कृते एव विरचिता:॥ सर्वा: उपनिषद: संस्कृते उपनिबद्घाः। अन्ये ग्रन्था: - शिक्षा, कल्प, निरुक्त, ज्योतिष, छन्द, व्याकरण, वेदाङ्ग, दर्शन, इतिहास, पुराण, काव्य, शास्त्र: चेत्यादयः ॥ महर्षि-पाणिनिना विरचिता अष्टाध्यायी इति संस्कृतव्याकरणम् अधुनापि भारते विदेशेषु च भाषाविज्ञानिनां प्रेरणास्थानं वर्तते ॥ वाक्यकारं वररुचिं भाष्यकारं पतंजलिम् | पाणिनिं सूत्रकारं च प्रणतोस्मि मुनित्रयम् ॥", 'scots' => "Anglian speakers wis weel staiblisht in sooth-east Scotland by the 7t century. In the 13t century Norman landawners an thair reteeners, speakin Northumbrian Middle Inglis, wis inveetit tae come an sattle by the Keeng.", 'scots_gaelic' => "Ciamar a tha thu? Dè an t-ainm a tha ort? Dè a tha seo?", 'serbian' => "Gajica je objavljena je 1830. godine u Zagrebu u „kratkoj osnovi horvatsko-slavonskoga pravopisa“. Razvio ju je Ljudevit Gaj.", 'serbian_cyrillic' => "Као и када су други језици у питању, неопходно је разграничити појам језичких система којим се Срби како етницитет служе од стандардног језика који се употребљава у државним и културним институцијама.", 'simpl_chinese' => "现代标准汉语,是普通话、国语、华语的统称,指通行于中国大陆和香港、澳门、台湾、海外华人的共通语文,为现代汉语共通的交际口语与书面语,是联合国官方语言之一,是国际人士学习汉语言的主要参照。", 'slovak' => "Ak ste nedávno napísali tento článok, skúste vyčistiť jeho vyrovnávaciu pamäť alebo chvíľu počkať predtým, než ho znova vytvoríte.", 'slovenian' => "Slovénščina je južnoslovanski jezik z okoli 2,2 milijonoma govorcev po svetu, od katerih jih večina živi v Sloveniji. Je eden redkih indoevropskih jezikov, ki je še ohranil dvojino.", 'spanish' => "El castellano es lengua oficial de España. También se habla en Gibraltar[70] y en Andorra (donde es la lengua materna mayoritaria debido a la inmigración, pero no es la lengua propia y oficial como sí lo es el catalán[71] ).", 'swahili' => "Lugha hii ina utajiri mkubwa wa misamiati na misemo na mithali na mashairi na mafumbo na vitendawili na nyimbo.", 'swedish' => "Hej. Hur är det? Bara bra, tack. Förlåt, jag har glömt, varifrån kommer du nu igen?", 'tagalog' => "Ang Wikibooks ay isang ambagang proyekto sa pagkagawa ng isang koleksyon ng mga libre at malayang-kontentong pang-araling aklat na pwede mong baguhin.", 'tamil' => "நீங்கள் ஆங்கிலம் பேசுவீர்களா?", 'thai' => "ภาษาไทย เป็นภาษาราชการของประเทศไทย และภาษาแม่ของชาวไทย และชนเชื้อสายอื่นในประเทศไทย ภาษาไทยเป็นภาษาในกลุ่มภาษาไต ซึ่งเป็นกลุ่มย่อยของตระกูลภาษาไท-กะได สันนิษฐานว่า", 'trad_chinese' => "中華民國,在亞東之極,本都南京,因事失地泰半,暫遷於臺北。其東以鴨綠江界朝鮮國,隔東海望日本。其北與俄羅斯相接。其西有大山,天下至高者也。而皆失於內戰,今僅得臺灣及其周圍矣。", 'turkish' => "Bu kitapta Türkçe konuşmak, yazmak ve okumak için gereken her şeyi bulacaksınız.", 'ukrainian' => "Українська мова є мовою найбільшого корінного етносу України і невід'ємною базовою ознакою його ідентичності протягом багатьох століть.", 'vietnamese' => "Tiếng Việt là ngôn ngữ chính thức tại Việt Nam, và cũng là ngôn ngữ phổ thông đối với các dân tộc thiểu số tại Việt Nam.", 'welsh' => "Gan nad oedd y Frythoneg yn iaith ysgrifenedig tystiolaeth anuniongyrchol yn unig sydd i'r newidiadau a ddigwyddodd iddi.", 'yiddish' => "יידיש אדער אידיש (Yiddish) גערופֿן ביי אידן אלס מאַמע לשון, איז אַ שפּראַך װאָס װערט הײַנט גערעדט ביי 1.5 מיליאָן יידן[1] און באַקאַנט ביי 3,142,560 מיליאָן [2] מענטשן איבער דער װעלט, בעיקר פֿונעם אַשכנזישן אָפּשטאַם.", 'yoruba' => "Èdè Yorùbá Ní báyìí, tí a bá wo èdè Yorùbá, àwon onímò pín èdè náà sábée èyà wa nínú e bí èdè Niger-Congo. Wón tún fìdí rè múlè pé èyà wa yìí ló wópò jùlo ní síso, ní ìwò oòrùn aláwò dúdú fún egbe-egbèrún odún." ); function TestInternationalization() { $this->UnitTestCase('Internationalization library - main/inc/lib/internationalization.lib.test.php'); } /** * ---------------------------------------------------------------------------- * Multibyte string conversion functions * ---------------------------------------------------------------------------- */ public function test_api_convert_encoding() { $string = 'xxxáéíóú?€'; // UTF-8 $from_encoding = 'UTF-8'; $to_encoding = 'ISO-8859-15'; $res = api_convert_encoding($string, $to_encoding, $from_encoding); $this->assertTrue(is_string($res)); $this->assertTrue(api_convert_encoding($res, $from_encoding, $to_encoding) == $string); //var_dump($res); //var_dump(api_convert_encoding($res, $from_encoding, $to_encoding)); } public function test_api_utf8_encode() { $string = 'xxxáéíóú?€'; // UTF-8 $from_encoding = 'ISO-8859-15'; $string1 = api_utf8_decode($string, $from_encoding); $res = api_utf8_encode($string1, $from_encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res == $string); //var_dump($res); } public function test_api_utf8_decode() { $string = 'xxxx1ws?!áéíóú@€'; // UTF-8 $to_encoding = 'ISO-8859-15'; $res = api_utf8_decode($string, $to_encoding); $this->assertTrue(is_string($res)); $this->assertTrue(api_utf8_encode($res, $to_encoding) == $string); //var_dump($res); } public function test_api_to_system_encoding() { $string = api_utf8_encode(get_lang('Title'), api_get_system_encoding()); $from_encoding = 'UTF-8'; $check_utf8_validity = false; $res = api_to_system_encoding($string, $from_encoding, $check_utf8_validity); $this->assertTrue(is_string($res)); $this->assertTrue(api_convert_encoding($res, $from_encoding, api_get_system_encoding()) == $string); //var_dump(api_utf8_encode($res, api_get_system_encoding())); } public function test_api_htmlentities() { $string = 'áéíóú@!?/\-_`*ç´`'; // UTF-8 $quote_style = ENT_QUOTES; $encoding = 'UTF-8'; $res = api_htmlentities($string, $quote_style, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue(api_convert_encoding($res, $encoding, 'HTML-ENTITIES') == $string); //var_dump($res); } public function test_api_html_entity_decode() { $string = 'áéíóú@/\!?Ç´`+*?-_ '; // UTF-8 $quote_style = ENT_QUOTES; $encoding = 'UTF-8'; $res = api_html_entity_decode(api_convert_encoding($string, 'HTML-ENTITIES', $encoding), $quote_style, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res == $string); //var_dump($res); } public function test_api_xml_http_response_encode() { $string='áéíóú@/\!?Ç´`+*?-_'; // UTF-8 $from_encoding = 'UTF-8'; $res = api_xml_http_response_encode($string, $from_encoding); $this->assertTrue(is_string($res)); //var_dump($res); } public function test_api_transliterate() { $string = 'Фёдор Михайлович Достоевкий'; // UTF-8 /* // If you have broken by mistake UTF-8 encoding of this source, try the following equivalent: $string = api_html_entity_decode( 'Фёдор '. 'Михайлович '. 'Достоевкий', ENT_QUOTES, 'UTF-8'); */ $unknown = 'X'; $from_encoding = 'UTF-8'; $res = api_transliterate($string, $unknown, $from_encoding); $this->assertTrue($res); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'Fyodor Mihaylovich Dostoevkiy'); //var_dump($string); //var_dump($res); } /** * ---------------------------------------------------------------------------- * Common multibyte string functions * ---------------------------------------------------------------------------- */ public function test_api_ord() { $encoding = 'UTF-8'; $characters = array('И', 'в', 'а', 'н', ' ', 'I', 'v', 'a', 'n'); // UTF-8 $codepoints = array(1048, 1074, 1072, 1085, 32, 73, 118, 97, 110); $res = array(); foreach ($characters as $character) { $res[] = api_ord($character, $encoding); } $this->assertTrue($res == $codepoints); //var_dump($res); } public function test_api_str_ireplace() { $search = 'Á'; // UTF-8 $replace = 'a'; $subject = 'bájando'; // UTF-8 $count = null; $encoding = 'UTF-8'; $res = api_str_ireplace($search, $replace, $subject, & $count, $encoding); $this->assertTrue($res); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'bajando'); //var_dump($res); } public function test_api_str_split() { $string = 'áéíóúº|\/?Ç][ç]'; // UTF-8 $split_length = 1; $encoding = 'UTF-8'; $res = api_str_split($string, $split_length, $encoding); $this->assertTrue(is_array($res)); $this->assertTrue(count($res) == 15); //var_dump($res); } public function test_api_stripos() { $haystack = 'bájando'; // UTF-8 $needle = 'Á'; $offset = 0; $encoding = 'UTF-8'; $res = api_stripos($haystack, $needle, $offset, $encoding); $this->assertTrue(is_numeric($res)|| is_bool($res)); $this->assertTrue($res == 1); //var_dump($res); } public function test_api_stristr() { $haystack = 'bájando'; // UTF-8 $needle = 'Á'; $part = false; $encoding = 'UTF-8'; $res = api_stristr($haystack, $needle, $part, $encoding); $this->assertTrue(is_bool($res) || is_string($res)); $this->assertTrue($res == 'ájando'); //var_dump($res); } public function test_api_strlen() { $string='áéíóúº|\/?Ç][ç]'; // UTF-8 $encoding = 'UTF-8'; $res = api_strlen($string, $encoding); $this->assertTrue(is_numeric($res)); $this->assertTrue($res == 15); //var_dump($res); } public function test_api_strpos() { $haystack = 'bájando'; // UTF-8 $needle = 'á'; $offset = 0; $encoding = 'UTF-8'; $res = api_strpos($haystack, $needle, $offset, $encoding); $this->assertTrue(is_numeric($res)|| is_bool($res)); $this->assertTrue($res == 1); //var_dump($res); } public function test_api_strrchr() { $haystack = 'aviación aviación'; // UTF-8 $needle = 'ó'; $part = false; $encoding = 'UTF-8'; $res = api_strrchr($haystack, $needle, $part, $encoding); $this->assertTrue(is_string($res)|| is_bool($res)); $this->assertTrue($res == 'ón'); //var_dump($res); } public function test_api_strrev() { $string = 'áéíóúº|\/?Ç][ç]'; // UTF-8 $encoding = 'UTF-8'; $res = api_strrev($string, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res == ']ç[]Ç?/\|ºúóíéá'); //var_dump($res); } public function test_api_strripos() { $haystack = 'aviación aviación'; // UTF-8 $needle = 'Ó'; $offset = 0; $encoding = 'UTF-8'; $res = api_strripos($haystack, $needle, $offset, $encoding); $this->assertTrue(is_numeric($res) || is_bool($res)); $this->assertTrue($res == 15); //var_dump($res); } public function test_api_strrpos() { $haystack = 'aviación aviación'; // UTF-8 $needle = 'ó'; $offset = 0; $encoding = 'UTF-8'; $res = api_strrpos($haystack, $needle, $offset, $encoding); $this->assertTrue(is_numeric($res) || is_bool($res)); $this->assertTrue($res == 15); //var_dump($res); } public function test_api_strstr() { $haystack = 'aviación'; // UTF-8 $needle = 'ó'; $part = false; $encoding = 'UTF-8'; $res = api_strstr($haystack, $needle, $part, $encoding); $this->assertTrue(is_bool($res)|| is_string($res)); $this->assertTrue($res == 'ón'); //var_dump($res); } public function test_api_strtolower() { $string = 'áéíóúº|\/?Ç][ç]'; // UTF-8 $encoding = 'UTF-8'; $res = api_strtolower($string, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'áéíóúº|\/?ç][ç]'); //var_dump($res); } public function test_api_strtoupper() { $string='áéíóúº|\/?Ç][ç]'; // UTF-8 $encoding = 'UTF-8'; $res = api_strtoupper($string, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res =='ÁÉÍÓÚº|\/?Ç][Ç]'); //var_dump($res); } public function test_api_substr() { $string = 'áéíóúº|\/?Ç][ç]'; // UTF-8 $start = 10; $length = 4; $encoding = 'UTF-8'; $res = api_substr($string, $start, $length, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'Ç][ç'); //var_dump($res); } public function test_api_substr_replace() { $string = 'áéíóúº|\/?Ç][ç]'; // UTF-8 $replacement = 'eiou'; $start= 1; $length = 4; $encoding = 'UTF-8'; $res = api_substr_replace($string, $replacement, $start, $length, $encoding); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'áeiouº|\/?Ç][ç]'); //var_dump($res); } public function test_api_ucfirst() { $string = 'áéíóúº|\/? xx ][ xx ]'; // UTF-8 $encoding = 'UTF-8'; $res = api_ucfirst($string, $encoding); $this->assertTrue($res); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'Áéíóúº|\/? xx ][ xx ]'); //var_dump($res); } public function test_api_ucwords() { $string = 'áéíóúº|\/? xx ][ xx ]'; // UTF-8 $encoding = 'UTF-8'; $res = api_ucwords($string, $encoding); $this->assertTrue($res); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'Áéíóúº|\/? Xx ][ Xx ]'); //var_dump($res); } /** * ---------------------------------------------------------------------------- * String operations using regular expressions * ---------------------------------------------------------------------------- */ public function test_api_preg_match() { $pattern = '/иван/i'; // UTF-8 $subject = '-- Ivan (en) -- Иван (bg) --'; // UTF-8 $matches = null; $flags = 0; $offset = 0; $encoding = 'UTF-8'; $res = api_preg_match($pattern, $subject, $matches, $flags, $offset, $encoding); $this->assertTrue($res == 1); //var_dump($res); //var_dump($matches); } public function test_api_preg_match_all() { $pattern = '/иван/i'; // UTF-8 $subject = '-- Ivan (en) -- Иван (bg) -- иван --'; // UTF-8 $matches = null; $flags = PREG_PATTERN_ORDER; $offset = 0; $encoding = 'UTF-8'; $res = api_preg_match_all($pattern, $subject, $matches, $flags, $offset, $encoding); $this->assertTrue($res == 2); //var_dump($res); //var_dump($matches); } public function test_api_preg_replace() { $pattern = '/иван/i'; // UTF-8 $replacement = 'ИВАН'; // UTF-8 $subject = '-- Ivan (en) -- Иван (bg) -- иван --'; // UTF-8 $limit = -1; $count = null; $encoding = 'UTF-8'; $res = api_preg_replace($pattern, $replacement, $subject, $limit, $count, $encoding); $this->assertTrue($res == '-- Ivan (en) -- ИВАН (bg) -- ИВАН --'); // UTF-8 //var_dump($res); } public function test_api_preg_split() { $pattern = '/иван/i'; // UTF-8 $subject = '-- Ivan (en) -- Иван (bg) -- иван --'; // UTF-8 $limit = -1; $count = null; $encoding = 'UTF-8'; $res = api_preg_split($pattern, $subject, $limit, $count, $encoding); $this->assertTrue($res[0] == '-- Ivan (en) -- '); // UTF-8 //var_dump($res); } /** * ---------------------------------------------------------------------------- * Obsolete string operations using regular expressions, to be deprecated * ---------------------------------------------------------------------------- */ public function test_api_ereg() { $pattern = 'scorm/showinframes.php([^"\'&]*)(&|&)file=([^"\'&]*)$'; $string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&file=test.php'; $regs = array(); $res = api_ereg($pattern, $string, $regs); $this->assertTrue(is_numeric($res)); //var_dump($regs); //var_dump($res); } public function test_api_eregi() { $pattern = 'scorm/showinframes.php([^"\'&]*)(&|&)file=([^"\'&]*)$'; $string = 'http://localhost/dokeos/main/scorm/showinframes.php?id=5&file=test.php'; $regs = array(); $res = api_eregi($pattern, $string, $regs); $this->assertTrue(is_numeric($res)); //var_dump($regs); //var_dump($res); } /** * ---------------------------------------------------------------------------- * String comparison * ---------------------------------------------------------------------------- */ public function test_api_strcasecmp() { $string1 = 'áéíóu'; // UTF-8 $string2 = 'Áéíóu'; // UTF-8 $language = 'english'; $encoding = 'UTF-8'; $res = api_strcasecmp($string1, $string2, $language, $encoding); $this->assertTrue(is_numeric($res)); $this->assertTrue($res == 0); //var_dump($res); } public function test_api_strcmp() { $string1 = 'áéíóu'; // UTF-8 $string2 = 'Áéíóu'; // UTF-8 $language = 'english'; $encoding = 'UTF-8'; $res = api_strcmp($string1, $string2, $language, $encoding); $this->assertTrue(is_numeric($res)); $this->assertTrue($res == 1); //var_dump($res); } public function test_api_strnatcmp() { $string1 = '201áéíóu.txt'; // UTF-8 $string2 = '30áéíóu.TXT'; // UTF-8 $language = 'english'; $encoding = 'UTF-8'; $res = api_strnatcmp($string1, $string2, $language, $encoding); $this->assertTrue(is_numeric($res)); $this->assertTrue($res == 1); //var_dump($res); } /** * ---------------------------------------------------------------------------- * Sorting arrays * ---------------------------------------------------------------------------- */ public function test_api_natsort() { $array = array('img12.png', 'img10.png', 'img2.png', 'img1.png'); // UTF-8 $language = 'english'; $encoding = 'UTF-8'; $res = api_natsort($array, $language, $encoding); $keys = array_keys($array); $this->assertTrue(is_bool($res)); $this->assertTrue($array[$keys[0]] == 'img1.png'); //var_dump($array); //var_dump($res); } public function test_api_natrsort() { $array = array('img2.png', 'img10.png', 'img12.png', 'img1.png'); // UTF-8 $language = 'english'; $encoding = 'UTF-8'; $res = api_natrsort($array, $language, $encoding); $keys = array_keys($array); $this->assertTrue(is_bool($res)); $this->assertTrue($array[$keys[0]] == 'img12.png'); //var_dump($array); //var_dump($res); } /** * ---------------------------------------------------------------------------- * Encoding management functions * ---------------------------------------------------------------------------- */ public function test_api_refine_encoding_id() { $encoding = 'koI8-r'; $res = api_refine_encoding_id($encoding); $this->assertTrue($res); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'KOI8-R'); //var_dump($res); } public function test_api_equal_encodings() { $encoding1 = 'cp65001'; $encoding2 = 'utf-8'; $encoding3 = 'WINDOWS-1251'; $encoding4 = 'WINDOWS-1252'; $encoding5 = 'win-1250'; $encoding6 = 'windows-1250'; $res1 = api_equal_encodings($encoding1, $encoding2); $res2 = api_equal_encodings($encoding3, $encoding4); $res3 = api_equal_encodings($encoding5, $encoding6); $res4 = api_equal_encodings($encoding5, $encoding6, true); $this->assertTrue(is_bool($res1)); $this->assertTrue(is_bool($res2)); $this->assertTrue(is_bool($res3)); $this->assertTrue(is_bool($res4)); $this->assertTrue($res1); $this->assertTrue(!$res2); $this->assertTrue($res3); $this->assertTrue(!$res4); //var_dump($res1); //var_dump($res2); //var_dump($res3); //var_dump($res4); } public function test_api_is_utf8() { $encoding = 'cp65001'; // This an alias of UTF-8. $res = api_is_utf8($encoding); $this->assertTrue(is_bool($res)); $this->assertTrue($res); //var_dump($res); } public function test_api_get_system_encoding() { $res = api_get_system_encoding(); $this->assertTrue(is_string($res)); $this->assertTrue($res); //var_dump($res); } public function test_api_is_encoding_supported() { $encoding1 = 'UTF-8'; $encoding2 = 'XXXX#%#%VR^%BBDNdjlrsg;d'; $res1 = api_is_encoding_supported($encoding1); $res2 = api_is_encoding_supported($encoding2); $this->assertTrue(is_bool($res1) && is_bool($res2)); $this->assertTrue($res1 && !$res2); //var_dump($res1); //var_dump($res2); } public function test_api_get_non_utf8_encoding() { $language = 'bulgarian'; $res = api_get_non_utf8_encoding($language); $this->assertTrue($res); $this->assertTrue(is_string($res)); $this->assertTrue($res == 'WINDOWS-1251'); //var_dump($res); } public function test_api_detect_encoding_html() { $meta = ''."\n"; $head1 = '
'."\n".'This is a sample document for testing encoding detection.
'."\n"; $body2 = ''."\n".$body1.''; $html1 = $body1; // A html-snippet, see for example some log-files created by the "Chat" tool. $html2 = ''."\n".$head1.$body2."\n".''; // A full html-document, no encoding has been declared. $html3 = ''."\n".$head2.$body2."\n".''; // A full html-document, encoding has been declared. $res1 = api_detect_encoding_html($html1); $res2 = api_detect_encoding_html($html2); $res3 = api_detect_encoding_html($html3); $this->assertTrue( $res1 === 'UTF-8' && $res2 === 'UTF-8' && $res3 === 'ISO-8859-15' ); //var_dump($res1); //var_dump($res2); //var_dump($res3); } public function test_api_detect_encoding_xml() { $xml1 = '