Certain characters not showing up
#1
Posted 27 January 2013 - 08:19 PM
#2
Posted 27 January 2013 - 08:35 PM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
#3
Posted 27 January 2013 - 09:07 PM
Thanks!You'll need to have your character encoding set to UTF-8, both in MySQL and your PHP generated HTML.
#4
Posted 27 January 2013 - 09:36 PM
#5
Posted 27 January 2013 - 09:37 PM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
#6
Posted 27 January 2013 - 09:46 PM
#7
Posted 27 January 2013 - 11:00 PM
You'll need to have your character encoding set to UTF-8, both in MySQL and your PHP generated HTML.
#8
Posted 28 January 2013 - 07:05 AM
Thanks, I think this is the last question!
#9
Posted 28 January 2013 - 07:44 AM
Though this is only true for the functions that actually manipulate the string data that contains UTF-8 characters, it's better to treat all strings as if they were UTF-8. That way you are ensured that you will not encounter any future bugs, related to differing charsets.
That said, I suspect there are one or two places where you've might have forgotten to define the proper charset:
- On the database connection, with
*_set_charset (). - In the HTTP headers themselves, with the proper
header ()call.
The latter one is necessary because the meta-HTML headers are ignored by the browser, if they conflict with a HTTP header. So if your web-server is set to serve HTML as ISO-8859-1 by default (which a lot of them are), then your "meta http-equiv" HTML header is quite ineffective.
I also recommend reading the article "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)". As it says: It's the absolute minimum, and no excuses!
#10
Posted 28 January 2013 - 08:44 AM
Thanks. I tried this:The functions you use in PHP to manipulate the data have to be UTF-8 compatible as well, yes.
Though this is only true for the functions that actually manipulate the string data that contains UTF-8 characters, it's better to treat all strings as if they were UTF-8. That way you are ensured that you will not encounter any future bugs, related to differing charsets.
That said, I suspect there are one or two places where you've might have forgotten to define the proper charset:
- On the database connection, with
*_set_charset ().- In the HTTP headers themselves, with the proper
header ()call.
The latter one is necessary because the meta-HTML headers are ignored by the browser, if they conflict with a HTTP header. So if your web-server is set to serve HTML as ISO-8859-1 by default (which a lot of them are), then your "meta http-equiv" HTML header is quite ineffective.
I also recommend reading the article "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)". As it says: It's the absolute minimum, and no excuses!
/* change character set to utf8 */
if (!mysqli_set_charset($con, "utf8")) {
printf("Error loading character set utf8: %s\n", mysqli_error($con));
} else {
printf("Current character set: %s\n", mysqli_character_set_name($con));
}
to test, and the output was "Error loading character set utf8:" I don't understand.
#11
Posted 28 January 2013 - 08:49 AM
- I don't know what library you're using to communicate with the database.
- And in any case, you really should be using MySQLI or PDO.
Since you got the error message, I'm assuming that you're still using the old and outdated mysql library. I recommend updating your scripts to use the current libraries, before the old one is completely removed from PHP. Alternatively, use the old mysql_* version of the function, in the meantime.
#12
Posted 30 January 2013 - 03:11 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












