472,805 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

unicode entities from characters

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. :-)
Sep 1 '06 #1
6 2530

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!
Sep 1 '06 #2

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? :-)
Sep 1 '06 #3
*** 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 programacin web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Sep 2 '06 #4
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(
'&iexcl;' ='¡',
'&cent;' ='¢',
'&pound;' ='£',
'&yen;' ='¥',
'&ordf;' ='ª',
'&laquo;' ='«',
'&deg;' ='°',
'&cedil;' ='¸',
'&raquo;' ='»',
'&iquest;' ='¿',
'&Agrave;' ='À',
'&Aacute;' ='Á',
'&Acirc;' ='Â',
'&Atilde;' ='Ã',
'&Auml;' ='Ä',
'&Aring;' ='Å',
'&AElig;' ='Æ',
'&Ccedil;' ='Ç',
'&Egrave;' ='È',
'&Eacute;' ='É',
'&Ecirc;' ='Ê',
'&Euml;' ='Ë',
'&Igrave;' ='Ì',
'&Iacute;' ='Í',
'&Icirc;' ='Î',
'&Iuml;' ='Ï',
'&ETH;' ='Ð',
'&Ntilde;' ='Ñ',
'&Ograve;' ='Ò',
'&Oacute;' ='Ó',
'&Ocirc;' ='Ô',
'&Otilde;' ='Õ',
'&Ouml;' ='Ö',
'&times;' ='×',
'&Oslash;' ='Ø',
'&Ugrave;' ='Ù',
'&Uacute;' ='Ú',
'&Ucirc;' ='Û',
'&Uuml;' ='Ü',
'&Yacute;' ='Ý',
'&THORN;' ='Þ',
'&szlig;' ='ß',
'&agrave;' ='à',
'&aacute;' ='á',
'&acirc;' ='â',
'&atilde;' ='ã',
'&auml;' ='ä',
'&aring;' ='å',
'&aelig;' ='æ',
'&ccedil;' ='ç',
'&egrave;' ='è',
'&eacute;' ='é',
'&ecirc;' ='ê',
'&euml;' ='ë',
'&igrave;' ='ì',
'&iacute;' ='í',
'&icirc;' ='î',
'&iuml;' ='ï',
'&eth;' ='ð',
'&ntilde;' ='ñ',
'&ograve;' ='ò',
'&oacute;' ='ó',
'&ocirc;' ='ô',
'&otilde;' ='õ',
'&ouml;' ='ö',
'&divide;' ='÷',
'&oslash;' ='ø',
'&ugrave;' ='ù',
'&uacute;' ='ú',
'&ucirc;' ='û',
'&uuml;' ='ü',
'&yacute;' ='ý',
'&thorn;' ='þ',
'&yuml;' ='ÿ',
'&fnof;' ='ƒ',
'&rang;' ='〉',
'&loz;' ='◊',
'&quot;' ='"',
'&amp;' ='&',
'&lt;' ='<',
'&gt;' ='>',
'&OElig;' ='Œ',
'&oelig;' ='œ',
'&Scaron;' ='Š',
'&scaron;' ='š',
'&Yuml;' ='Ÿ',
'&circ;' ='ˆ',
'&tilde;' ='˜',
'&euro;' ='€');
//
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 :-(((
Sep 2 '06 #5
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 "&apos;". 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/

Sep 2 '06 #6
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 "&apos;". 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
Sep 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: krammer | last post by:
Hello, I have the following questions that I have not been able to find any *good* answers for. Your help would me much appreciated!, fyi, I am a Java XML guy and I have no experience with SGML...
27
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
5
by: Nancy | last post by:
I recently completed a web page, "Browser Tests of Entities in 2004". http://www.santagata.us/characters/CharacterEntities.html It shows those characters that work in all of the version 5.2+...
32
by: Wolfgang Draxinger | last post by:
I understand that it is perfectly possible to store UTF-8 strings in a std::string, however doing so can cause some implicaions. E.g. you can't count the amount of characters by length() | size()....
8
by: lorenzo.viscanti | last post by:
X-No-Archive: yes Hi, I've found lots of material on the net about unicode html conversions, but still i'm having many problems converting unicode characters to html entities. Is there any...
6
by: Bill Nguyen | last post by:
I'm getting data from a mySQL database (default char set = UTF-8). I need to display data in Unicode but got only mongolian characters like this: Phạm Thị Ngọc I changed the textbox font to...
2
by: Frantic | last post by:
I'm working on a list of japaneese entities that contain the entity, the unicode hexadecimal code and the xml/sgml entity used for that entity. A unicode document is read into the program, then the...
3
by: Laangen_LU | last post by:
Dear Group, my first post to this group, so if I'm on the wrong group, my apologies. I'm trying to send out an email in Chinese lanuage using the mail() function in PHP. Subject and...
25
by: Simon | last post by:
Hello - I'm working on a team that is planning to add Welsh language support to a large existing IT system which is partially web-based and English-language-only so far. I've heard that 2...
2
by: neovantage | last post by:
hey geeks, I am using a function which convert unicode to entities. So that i can save values into mysql database into entities. This function really helps me when i display the store entity data...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.