Re: How to upload form data containing special characters correctly?



Wim Cossement wrote:
Jerry Stuckle wrote:


You'll need to select the correct character set for MySQL. It might be utf-8, as some have suggested, but you might find another charaset more applicable. See the MySQL doc and comp.databases.mysql newsgroup for more info on mysql topics.


Well, I've been hearing for a while UTF-8 is the best for all that stuff, so tables and DB's are all in utf8_general_ci (does anyone know the difference between that and utf8_bin, and what's utf8_unicode_ci doing in that list)


That some peoples opinions. And remember, they are opinions. Some people know what they're talking about, and some don't. Take anything you get on the internet (including this) with a grain of salt.

Personally, I use the characterset which matches my data. This may or may not be utf-8.

Also, rather than use addslashes() you should use mysql_real_escape_string() to escape your characters.


Some like the other better, there are still discussions going on... :-)
http://www.sitepoint.com/forums/showthread.php?t=337881


Not much discussion. addslashes() is a PHP construct which escapes certain characters. mysql_real_escape_string() is a mysql function to escape the characters necessary to place the data in a mysql database using the current charset.

mysql_real_escape_string needs no special processing when reading the data out - the data is exactly as it was before mysql_real_escape_string was called. That is not the case for addslashes().

You shouldn't use htmlspecialchars() for storing data into the database; that's a display issue, not a storage issue. You should only use it when displaying data (if necessary).


The fact is that the data does not realy need to be displayed in a webpage, this is just for uploading. I'll rather use OpenOffice with MyODBC to edit the data when needed and use a report to display it.


That's fine. So don't use htmlspecialchars() at all then.

And also ensure you're using the correct character set on your html page to display the data.


I guess this is the case.
The header contains <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />

Now I'm going to try this and I'll let you know the outcome.

Thanks a bunch,

Wimmy


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: Special Characters in Query String
    ... I've had numerous problems with utf-8, ... in common characters in spanish not geting displayed. ... > available for encoding of characters. ... > If you can display your characters with ISO-8859-1, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Open html as source
    ... Word X -- Word X can't display most Unicode. ... characters as two symbols, so I suppose it forgot that it's UTF8. ... Choose UTF-8 at that point. ...
    (microsoft.public.mac.office.word)
  • Re: Unicode-based FreeBSD
    ... maps UTF-8 to 256 characters it is actually able to display. ... Or, in other words, always map from UTF-8. ... There are many applications that do not yet support UTF-8. ...
    (freebsd-current)
  • Problems with UTF8. Unicode, ADO and MySQL
    ... is stored in utf-8 format in order to accomodate for a wide range of ... W2003 server, making no changes, and then try to display the text from ... for non latin characters. ... seems to have little effect) and I have saved all my asp files in utf-8 ...
    (microsoft.public.data.ado)
  • Re: Print Spanish characters in Perl?
    ... be able to display the accented characters. ... I know that I need to specify ... saving as UTF-8, then including the text in an HTML page but forgetting ... ISO-Latin-1 and the non-ASCII characters will be messed up, ...
    (comp.lang.perl.misc)