=James Birkholz= wrote:
- mySQL can have its encoding changed at the levels of database, table
and column, all of which have defaults
[snip]
PHP 4.3.10 / mySQL 4.0.22
MySQL prior to 4.1 has only a single server-wide encoding setting which is used for collation and (non-binary) text comparison. Leave the default at 'latin1'; applications will deal with the UTF-8 data on their own.
mb_convert_encoding($theTown, "ISO-8859-1"); echo mb_detect_encoding($theTown); (outputs "UTF-8")
mb_convert_encoding takes three parameters; try specifying the 'from' encoding. Otherwise it'll default to whatever the default is set to (which is probably ISO-8859-1)...
If you're only going to use ISO-8859-1, consider also using the simpler utf8_encode() and utf8_decode() functions.
Note however that if your text includes Windows "extended" characters (curly quotes, long dashes, euro symbol, s-caron, c-caron, etc) all of these will be corrupted by a conversion from ISO-8859-1 to Unicode or vice-versa. You'll need to specify "Windows-1252" instead of "ISO-8859-1" to get the correct conversion to/from Unicode.
[snip]
mbstring.internal_encoding ISO-8859-1 no value
Yep. That conversion call has no effect because your source and destination encodings are the same.
iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "ISO-8859-1"); var_dump(iconv_get_encoding('all'));
and get Fatal error: Call to undefined function: iconv_set_encoding() in .... on line ....
iconv is a separate module entirely, unrelated to the mbstring module, and it looks like you don't have it compiled in or loaded. Did you mean to use mb_internal_encoding() to set mbstring's default encoding?
mysql_query("SET NAMES 'utf8'", $dbh);
but this is probably because my mySQL version doesn't support utf-8?
Right, this wouldn't do anything useful for you because your MySQL version predates support for character sets.
-- brion vibber (brion @ pobox.com)