In addition to the php and mySQL documentation, is there any place else to
learn more about dealing with encoding?
Here's what I think I know, tell me if I'm wrong:
* I have to deal with encoding (when the defaults don't work) for php,
mySQL and MW (when it passes parameters through extensions, and
subsequently final HTML display.
* mySQL can have its encoding changed at the levels of database, table and
column, all of which have defaults
* on a hosted situation where I don't control the mySQL as a root admin, I
need to use the ALTER sql commands to change the encoding
* you can tell mySQL what encodings the php will send and receive.
I'm still wrestling with using values passed from MW extensions in php
controlled mySQL queries. These values have diacritcals, and the data in
the mySQL tables have the same characters, but the MW encoding appears to
be UTF-8. I've tried changing the encoding of the value in php using
mb_convert_encoding(), but it stays UTF-8.
I use phpMyAdmin and if I set it to use Latin-1/ISO-8859-1, it runs the
queries correctly, but if I set it to Unicode/UTF-8 then it doesn't.
My host has me on:
PHP 4.3.10 / mySQL 4.0.22
Does my version of mySQL just not support Unicode/UTF-8? Even so, I would
think that I should be able to re-encode the variable values to Latin1. Am
I using the wrong function or syntax?
mb_convert_encoding($theTown, "ISO-8859-1");
echo mb_detect_encoding($theTown);
(outputs "UTF-8")
I tried this:
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 ....
here are some phpInfo values from my installation:
Directive Local Value Master Value
mbstring.detect_order no value no value
mbstring.encoding_translation Off Off
mbstring.func_overload 0 0
mbstring.http_input pass pass
mbstring.http_output pass pass
mbstring.internal_encoding ISO-8859-1 no value
mbstring.language neutral neutral
mbstring.substitute_character no value no value
and I've tried this with no desired effect:
$dbh=mysql_connect ($host, $username, $password) or die ('Connect error: '
. mysql_error());
mysql_select_db ($database) or die ('Cannot select database');
mysql_query("SET NAMES 'utf8'", $dbh);
but this is probably because my mySQL version doesn't support utf-8?
In summary, I think my php version should support converting encodings, but
so far the only way the I've been able to do it is to manually detect a
specific word and re-assing the same value in code like this:
if (ereg("Gr.+tz", $theKreis))
{
$theKreis = 'Grätz';
}
Unfortunately, I'm at the point where I have hundreds of values that use
special characters, instead of just a few.