<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <meta charset="utf-8" /> <title>NoorTy - Converter</title> <script> function NoorTyConverter() { var toeteJazuwlar = "([\u060c\u061f\u061b\u0621\u0627\u0628\u062a\u062c\u062d\u062f\u0631-\u0634\u0639\u0641-\u0646\u0648-\u064a\u067e\u0686\u06ad\u06af\u06be\u06c6\u06c7\u06cb\u06d5]+)"; this.cyrillic2arabic = function(a) { a = almastiruw(a, ["А", "Ә", "Б", "В", "Г", "Ғ", "Д", "Е", "Ё", "Ж", "З", "И", "Й", "К", "Қ", "Л", "М", "Н", "Ң", "О", "Ө", "П", "Р", "С", "Т", "У", "Ұ", "Ү", "Ф", "Х", "Һ", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ы", "І", "Ь", "Э", "Ю", "Я", "\\,", "\\;", "\\?"], ["ا", "ءا", "ب", "ۆ", "گ", "ع", "د", "ە", "يو", "ج", "ز", "ي", "ي", "ك", "ق", "ل", "م", "ن", "ڭ", "و", "ءو", "پ", "ر", "س", "ت", "ۋ", "ۇ", "ءۇ", "ف", "ح", "ھ", "س", "چ", "ش", "شش", "", "ى", "ءى", "", "ە", "يۋ", "يا", "،", "؛", "؟"], "gi"); a = a.replace(/ييا/g, "يا"); return a.replace(new RegExp(toeteJazuwlar, "g"), function(a) { function b(c) { return c.replace(/\u0621/g, ""); }; return (0 <= a.search(/\u0621/) && 0 > a.search(/[\u06af\u0643\u06d5]/)) ? "ء" + b(a) : b(a); }); } this.arabic2latin = function(a) { a = a.replace(new RegExp(toeteJazuwlar, "g"), function(a) { var b, c; b = ["ا", "ب", "ۆ", "گ", "ع", "د", "ە", "ج", "ز", "ي", "ك", "ق", "ل", "م", "ن", "ڭ", "و", "پ", "ر", "س", "ت", "ۋ", "ۇ", "ف", "ح", "ھ", "چ", "ش", "ى", "،", "؛", "؟"]; c = ["a", "b", "v", "g", "g'", "d", "e", "j", "z", "i'", "k", "q", "l", "m", "n", "n'", "o", "p", "r", "s", "t", "y'", "u", "f", "h", "h", "c'", "s'", "y", ",", ";", "?"]; if (0 > a.search(/[\u0621\u06d5\u06af\u0643]/)) { a = almastiruw(a, b, c, "g"); } else { a = almastiruw(a, b, c, "g"); a = a.replace(/([aou])/g, "$1'"); a = a.replace(/y(?!\')/g, "i"); a = a.replace(/\u0621/g, ""); }; return tuezetuew(a); }); return basAerip(a); } this.latin2cyrillic = function(a) { a = a.replace(/[\u2019\u2018\u0060]/g, "'"); a = a.replace(/([bdf-hj-np-tvz]|[cgnsy]')(i')(a)/gi, "$1$2$2$3"); a = almastiruw(a, ["A'", "a'", "C'", "c'", "G'", "g'", "I'", "i'", "N'", "n'", "O'", "o'", "S'", "s'", "U'", "u'", "Y'", "y'", "A", "a", "B", "b", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", "I", "i", "J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "Q", "q", "R", "r", "S", "s", "T", "t", "U", "u", "V", "v", "Y", "y", "Z", "z"], ["Ә", "ә", "Ч", "ч", "Ғ", "ғ", "И", "и", "Ң", "ң", "Ө", "ө", "Ш", "ш", "Ү", "ү", "У", "у", "А", "а", "Б", "б", "Д", "д", "Е", "е", "Ф", "ф", "Г", "г", "Х", "х", "І", "і", "Ж", "ж", "К", "к", "Л", "л", "М", "м", "Н", "н", "О", "о", "П", "п", "Қ", "қ", "Р", "р", "С", "с", "Т", "т", "Ұ", "ұ", "В", "в", "Ы", "ы", "З", "з"] ); a = a.replace(/([АаӘәОоӨөҰұҮүЫыІіЕе])и/g, "$1й"); a = a.replace(/([АаӘәОоӨөҰұҮүЫыІіЕе])И/g, "$1Й"); a = a.replace(/[ий][АаӘә]/g, "я"); a = a.replace(/[ИЙ][АаӘә]/g, "Я"); a = a.replace(/[ий][Уу]/g, "ю"); a = a.replace(/[ИЙ][Уу]/g, "Ю"); a = a.replace(/ш[Шш]/g, "щ"); a = a.replace(/Ш[Шш]/g, "Щ"); return a; } function basAerip(a) { a = a.toLowerCase(); a = a.replace(/([\n\u0021\u002e\u003f]+|^\s*)([\s\u0021-\u0040\u005b-\u0060\u007b-\u007e\u00a1-\u00bf\u00d7\u00f7]*)./g, function(a) { return a.toUpperCase(); }); return a; } function almastiruw(a, b, c, d) { d = d || "g"; for (var e in b) { a = a.replace(new RegExp(b[e], d), c[e]); } return a; } function tuezetuew(a) { var b, c; b = ["c'", "f", "v", "tele", "i'ka", "i'o'n", "ju'n'go", "[ln]i'[sz]"]; c = "([a-dfh-jl-z']*|g'*)"; a = a.replace( new RegExp("g'" + c + "|[qh]" + c + "|(a'.a')" + c + "|([er])" + c + "([ao])" + c + "|([a-z']*)(" + b.join("|") + ")([a-z']*)", "gi"), function(a) { return a.replace(/([aou])\'/gi, "$1"); } ); a = a.replace( new RegExp("g'" + c + "|[qh]" + c + "|[aou](?!')" + c, "gi"), function(a) { return a.replace(/i(?!\')/gi, "y"); } ); return almastiruw(a, ["ko'lba'i'", "a'y'zimen", "ba'simen"], ["ko'lbai'", "ay'zymen", "basymen"], "gi" ); } } </script> <style> textarea { display: block; width: 99%; height: 20em; } </style> </head> <body> <h1>NoorTy - Converter</h1> <textarea></textarea> <select> <option value="Latin2Cyrillic">Latin => Cyrillic</option> <option value="Cyrillic2Arabic">Cyrillic => Arabic</option> <option value="Arabic2Latin">Cyrillic => Arabic</option> </select> <button>Convert</button> <script> var Converter = new NoorTyConverter(); document.getElementsByTagName('button')[0].onclick = function() {document.getElementsByTagName('textarea')[0].value = (document.getElementsByTagName("select")[0].options[document.getElementsByTagName("select")[0].selectedIndex].value == "Cyrillic2Arabic") ? Converter.cyrillic2arabic(document.getElementsByTagName('textarea')[0].value) : ((document.getElementsByTagName("select")[0].options[document.getElementsByTagName("select")[0].selectedIndex].value == "Arabic2Latin") ? Converter.arabic2latin(document.getElementsByTagName('textarea')[0].value) : Converter.latin2cyrillic(document.getElementsByTagName('textarea')[0].value))} </script> </body> </html>
Kazakh Latin-Arabic-Cyrillic Converter
猜你喜欢
转载自www.cnblogs.com/nurtay/p/converter.html
今日推荐
周排行