Forum Moderators: coopster
All symbols below are allowed in a file using ANSI encoding, and will work for a webpage using the utf-8 charsheet. If you want to have any more symbols being converted you will need to use a database to develop the arrays, as the rest of the symbols are not recognised when saving in ANSI format.
I wanted to actually upload the file, but a wall of text will have to suffice:
<?php
/*
PhP Special Character to Numerical Code converter
Compiled by Michael Read
Contact me by sending a PM to Readie at http:/www.webmasterworld.com
Code may be used freely for all purposes and without citation
*/
/*
SYNTAX1 (Suggested):
Have the following line above the (echo $variable) in your PhP document:
------
include 'symbolreplace.php';
------
Then you have your usual variable declaration of the SQL column, but with a preg_replace string:
------
$sql = "SELECT * FROM database_table WHERE 1";
$rows = mysql_num_rows($result);
$result = mysql_query($sql);
for ($i = 0; $i < $rows; $i++){
$name = preg_replace($symb, $repl, mysql_result($result,$i,"name"));
}
------
*/
/*
SYNTAX2 (Not suggested):
Have the following line above the (echo $variable) in your PhP document:
------
include 'symbolreplace.php';
------
Then you have your usual variable declaration of the SQL column:
------
$sql = "SELECT * FROM database_table WHERE 1";
$rows = mysql_num_rows($result);
$result = mysql_query($sql);
for ($i = 0; $i < $rows; $i++){
$name = mysql_result($result,$i,"name");
}
------
And then, in the PhP loop where you want the variable to appear you would have:
------
echo preg_replace($symb, $repl, $name);
------
*/
$symb = array();
$symb[0] = '/À/';
$symb[1] = '/à/';
$symb[2] = '/Á/';
$symb[3] = '/á/';
$symb[4] = '/Â/';
$symb[5] = '/â/';
$symb[6] = '/Ã/';
$symb[7] = '/ã/';
$symb[8] = '/Ä/';
$symb[9] = '/ä/';
$symb[10] = '/Å/';
$symb[11] = '/å/';
$symb[12] = '/Æ/';
$symb[13] = '/æ/';
$symb[14] = '/Ç/';
$symb[15] = '/ç/';
$symb[16] = '/Ð/';
$symb[17] = '/Ð/';
$symb[18] = '/ð/';
$symb[19] = '/È/';
$symb[20] = '/è/';
$symb[21] = '/É/';
$symb[22] = '/é/';
$symb[23] = '/Ê/';
$symb[24] = '/ê/';
$symb[25] = '/Ë/';
$symb[26] = '/ë/';
$symb[27] = '/ƒ/';
$symb[28] = '/Ì/';
$symb[29] = '/ì/';
$symb[30] = '/Í/';
$symb[31] = '/í/';
$symb[32] = '/Î/';
$symb[33] = '/î/';
$symb[34] = '/Ï/';
$symb[35] = '/ï/';
$symb[36] = '/Ñ/';
$symb[37] = '/ñ/';
$symb[38] = '/Ò/';
$symb[39] = '/ò/';
$symb[40] = '/Ó/';
$symb[41] = '/ó/';
$symb[42] = '/Ô/';
$symb[43] = '/ô/';
$symb[44] = '/Õ/';
$symb[45] = '/õ/';
$symb[46] = '/Ö/';
$symb[47] = '/ö/';
$symb[48] = '/Ø/';
$symb[49] = '/ø/';
$symb[50] = '/Œ/';
$symb[51] = '/œ/';
$symb[52] = '/Š/';
$symb[53] = '/š/';
$symb[54] = '/ß/';
$symb[55] = '/Þ/';
$symb[56] = '/þ/';
$symb[57] = '/Ù/';
$symb[58] = '/ù/';
$symb[59] = '/Ú/';
$symb[60] = '/ú/';
$symb[61] = '/Û/';
$symb[62] = '/û/';
$symb[63] = '/Ü/';
$symb[64] = '/ü/';
$symb[65] = '/Ý/';
$symb[66] = '/ý/';
$symb[67] = '/Ÿ/';
$symb[68] = '/ÿ/';
$symb[69] = '/Ž/';
$symb[70] = '/ž/';
$repl = array();
$repl[0] = 'À';
$repl[1] = 'à';
$repl[2] = 'Á';
$repl[3] = 'á';
$repl[4] = 'Â';
$repl[5] = 'â';
$repl[6] = 'Ã';
$repl[7] = 'ã';
$repl[8] = 'Ä';
$repl[9] = 'ä';
$repl[10] = 'Å';
$repl[11] = 'å';
$repl[12] = 'Æ';
$repl[13] = 'æ';
$repl[14] = 'Ç';
$repl[15] = 'ç';
$repl[16] = 'Đ';
$repl[17] = 'Ð';
$repl[18] = 'ð';
$repl[19] = 'È';
$repl[20] = 'è';
$repl[21] = 'É';
$repl[22] = 'é';
$repl[23] = 'Ê';
$repl[24] = 'ê';
$repl[25] = 'Ë';
$repl[26] = 'ë';
$repl[27] = 'ƒ';
$repl[28] = 'Ì';
$repl[29] = 'ì';
$repl[30] = 'Í';
$repl[31] = 'í';
$repl[32] = 'Î';
$repl[33] = 'î';
$repl[34] = 'Ï';
$repl[35] = 'ï';
$repl[36] = 'Ñ';
$repl[37] = 'ñ';
$repl[38] = 'Ò';
$repl[39] = 'ò';
$repl[40] = 'Ó';
$repl[41] = 'ó';
$repl[42] = 'Ô';
$repl[43] = 'ô';
$repl[44] = 'Õ';
$repl[45] = 'õ';
$repl[46] = 'Ö';
$repl[47] = 'ö';
$repl[48] = 'Ø';
$repl[49] = 'ø';
$repl[50] = 'Œ';
$repl[51] = 'œ';
$repl[52] = 'Š';
$repl[53] = 'š';
$repl[54] = 'ß';
$repl[55] = 'Þ';
$repl[56] = 'þ';
$repl[57] = 'Ù';
$repl[58] = 'ù';
$repl[59] = 'Ú';
$repl[60] = 'ú';
$repl[61] = 'Û';
$repl[62] = 'û';
$repl[63] = 'Ü';
$repl[64] = 'ü';
$repl[65] = 'Ý';
$repl[66] = 'ý';
$repl[67] = 'Ÿ';
$repl[68] = 'ÿ';
$repl[69] = 'Ž';
$repl[70] = 'ž';
ksort($symb);
ksort($repl);
?>