Replacing special characters with their HTML equivalents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey everyone.  I have a question.  I have a web scraper that grabs
information from web pages that often contain characters such as vowels
with umlots (I know I spelled that wrong.)

The data is editable, so the characters show up unmodified in an
editable text box.  However, when I try to import the data into a MySQL
database, the first occurrence of such a character, along with the rest
of the string, is truncated from the result.  Not all special characters
cause the problem; vowels with macrons work, for example.

I don't know if it's failing during the actual query or if the character
is being filtered out at some earlier stage, but whatever the cause,
it's not working.

My question is, is there a way to replace these characters with their
HTML equivalents?  For example, the a with an umlot over the top is
ä in HTML, so before the query is made, and before the filtering on
the string is done, I'd like to replace that special character with its
HTML representation.  This allows the user to see the character while
it's in its text box, yet at the same time allow it to be successfully
imported into the database.

I know about str_replace, but assuming it's the right function for the
job, how would I go about representing these special characters in PHP
so that it will understand what I'm trying to do?

Thanks!

James
-- 
"Black holes are where God divided by zero." --Steven Wright

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux