Hi, is there a way to convert special characters inserted by a user in a
form INTO unicode entities? The output format should be numeric:
--->""", not "'". I tried htmlentities and htmlspecialchars but
they don't convert "à","è","é" etc. Should I write a custom function? I
can't find a native one. Thanks. :-) 6 2460
I need help but I still try, so...
I made up this:
<?php
$stringa = "' < £ ¤ ¥";
$convmap = array(0x80, 0xff, 0, 0xff);
$str = mb_encode_numericentity($stringa, $convmap, "ISO-8859-1");
echo $str;
?>
it is quite perfectly working but the first 2 characters are not
encoded. So: how can I change $convmap to encode the characters in the
function entity_to_decimal_value here? http://radekhulan.cz/item/php-script...ory/apache-php
Thanks!
by passing a $string I should get another effect too:
what is NOT a special character should not be encoded...
Please, can you help me? :-)
*** Platero escribió/wrote (Fri, 01 Sep 2006 19:29:07 +0200):
by passing a $string I should get another effect too:
what is NOT a special character should not be encoded...
What's a 'special character' and what isn't?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Alvaro G. Vicario ha scritto:
>
What's a 'special character' and what isn't?
hi, a special char can be "à è ì ò ù á ú ó ñ ... " while a non-special
char is a regular "a e i L "...
During the last hours the things are getting more complicated:
I used this function
function char_to_decimal_ent($string){
//
$inner_string = htmlentities($string,ENT_QUOTES);
$entity_array = array(
'¡' ='¡',
'¢' ='¢',
'£' ='£',
'¥' ='¥',
'ª' ='ª',
'«' ='«',
'°' ='°',
'¸' ='¸',
'»' ='»',
'¿' ='¿',
'À' ='À',
'Á' ='Á',
'Â' ='Â',
'Ã' ='Ã',
'Ä' ='Ä',
'Å' ='Å',
'Æ' ='Æ',
'Ç' ='Ç',
'È' ='È',
'É' ='É',
'Ê' ='Ê',
'Ë' ='Ë',
'Ì' ='Ì',
'Í' ='Í',
'Î' ='Î',
'Ï' ='Ï',
'Ð' ='Ð',
'Ñ' ='Ñ',
'Ò' ='Ò',
'Ó' ='Ó',
'Ô' ='Ô',
'Õ' ='Õ',
'Ö' ='Ö',
'×' ='×',
'Ø' ='Ø',
'Ù' ='Ù',
'Ú' ='Ú',
'Û' ='Û',
'Ü' ='Ü',
'Ý' ='Ý',
'Þ' ='Þ',
'ß' ='ß',
'à' ='à',
'á' ='á',
'â' ='â',
'ã' ='ã',
'ä' ='ä',
'å' ='å',
'æ' ='æ',
'ç' ='ç',
'è' ='è',
'é' ='é',
'ê' ='ê',
'ë' ='ë',
'ì' ='ì',
'í' ='í',
'î' ='î',
'ï' ='ï',
'ð' ='ð',
'ñ' ='ñ',
'ò' ='ò',
'ó' ='ó',
'ô' ='ô',
'õ' ='õ',
'ö' ='ö',
'÷' ='÷',
'ø' ='ø',
'ù' ='ù',
'ú' ='ú',
'û' ='û',
'ü' ='ü',
'ý' ='ý',
'þ' ='þ',
'ÿ' ='ÿ',
'ƒ' ='ƒ',
'⟩' ='〉',
'◊' ='◊',
'"' ='"',
'&' ='&',
'<' ='<',
'>' ='>',
'Œ' ='Œ',
'œ' ='œ',
'Š' ='Š',
'š' ='š',
'Ÿ' ='Ÿ',
'ˆ' ='ˆ',
'˜' ='˜',
'€' ='€');
//
return preg_replace(
"/&[A-Za-z]+;/",
" ",
strtr($inner_string,$entity_array) );
}
but when the data arrives to the db through $_POST, it arrives as
regular LATIN, not encoded :-(((
Platero wrote:
Hi, is there a way to convert special characters inserted by a user in a
form INTO unicode entities? The output format should be numeric:
--->""", not "'". I tried htmlentities and htmlspecialchars but
they don't convert "à","è","é" etc. Should I write a custom function? I
can't find a native one. Thanks. :-)
AFAIK, custom function is a better option. I have seen the
uniord() function that I added in to php manual's user note
<http://in.php.net/ord#46267is been widely used in similar contexts.
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Platero wrote:
Hi, is there a way to convert special characters inserted by a user in a
form INTO unicode entities? The output format should be numeric:
--->""", not "'". I tried htmlentities and htmlspecialchars but
they don't convert "Ã*","è","é" etc. Should I write a custom function? I
can't find a native one. Thanks. :-)
Take a look at http://us3.php.net/manual/en/function.utf8-encode.php
Specifically, the second comment, by user rocketman, may help you. (I have
no idea whether or not his function works, but if it does it might be what
you're looking for.)
The ord() function may also help, but be careful! It only works on ASCII
values, so it may not help at all. http://us2.php.net/ord
HTH,
--
Benjamin D. Esham bd*****@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
"I'm tall," said Ron inconsequentially.
— an amusing-without-context line from HBP This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by krammer |
last post: by
|
27 posts
views
Thread by EU citizen |
last post: by
|
5 posts
views
Thread by Nancy |
last post: by
|
32 posts
views
Thread by Wolfgang Draxinger |
last post: by
|
8 posts
views
Thread by lorenzo.viscanti |
last post: by
|
6 posts
views
Thread by Bill Nguyen |
last post: by
|
2 posts
views
Thread by Frantic |
last post: by
|
3 posts
views
Thread by Laangen_LU |
last post: by
|
25 posts
views
Thread by Simon |
last post: by
| | | | | | | | | | | |