hello, will someone help me convert this javascript to php. itz a code that change a text to proper vietnamese characters.
tell me how to reconstruct the code below into a function text2viet("string"); in php.. thankx
var viqrData = new Array // Viet VIQR Map
(
// vietchas: = 24 Vowels + d + D
new Array( "a", "a", "a(", "e", "e", "i", "o", "o", "o+", "u", "u+", "y",
"A", "A", "A(", "E", "E", "I", "O", "O", "O+", "U", "U+","Y", "d", "D"),
new Array( "a'", "a'", "a('", "e'", "e'", "i'", "o'", "o'", "o+'", "u'", "u+'", "y'",
"A'", "A'", "A('", "E'", "E'", "I'", "O'", "O'", "O+'", "U'", "U+'", "Y'", "dd", "DD"),
new Array( "a", "a", "a(", "e^", "e", "i", "o", "o", "o+", "u", "u+", "y",
"A", "A", "A(", "E^", "E", "I", "O", "O", "O+", "U", "U+", "Y"),
new Array( "a?", "a?", "a(?", "e?", "e?", "i?", "o?", "o?", "o+?", "u?", "u+?", "y?",
"A?", "A?", "A(?", "E?", "E?", "I?", "O?", "O?", "O+?", "U?", "U+?", "Y?"),
new Array( "a~", "a~", "a(~", "e~", "e~", "i~", "o~", "o~", "o+~", "u~", "u+~", "y~",
"A~", "A~", "A(~", "E~", "E~", "I~", "O~", "O~", "O+~", "U~", "U+~", "Y~"),
new Array( "a.","a.", "a(.", "e.","e.", "i.", "o.", "o.", "o+.", "u.", "u+.", "y.",
"A.", "A.", "A(.", "E.", "E.", "I.", "O.", "O.", "O+.", "U.", "U+.", "Y.")
);
function VIQR2Unicode(txtarea)
{
// These are the main accent chars for viqr used in j
var strTA = txtarea.value; // equal to all the text in the text area
var strTemp = ""; // initialise a temp holder
var curViqrChar;
var uniChar;
var lastPos;
var lastChar;
var strBase;
var blnReplace;
var count = 1;
var lth = accentBase.length;
txtDiv.innerHTML = VIQR2Uni;
// loop through all the characters in the text area
for (var i=0; i < strTA.length; i++) {
curViqrChar = strTA.charAt(i);
if (curViqrChar == '*') (curViqrChar = '+');
if (curViqrChar == "\n") {
count += 1;
window.status = "Converting Line: " + count;
}
blnReplace = false;
// loop through all the accents in the accents array
for (var j=1; (j<lth)&&(!blnReplace); j++) {
if (curViqrChar == accentBase[j]){ // get the accent
lastPos = strTemp.length - 1;
lastChar = strTemp.charAt(lastPos); // in Unicode
for (var l=0; (l<26)&&(!blnReplace) ; l++) {
strBase = String.fromCharCode(uniData[0][l]);
if (lastChar == strBase) {
uniChar = vowelComposer(l,j,-1);
if (uniChar != "") {
strTemp = strTemp.substring(0, lastPos);
strTemp = strTemp + uniChar;
blnReplace = true;
break;
}
}
}
}
}
if (blnReplace == false) strTemp += strTA.charAt(i);
}
window.status = "Done";
txtarea.value = strTemp;
}