Paer Toernell
asked on
Delphi to mysql to html
A user enters text into a Delphi program, Delphi puts it into a MySQL table. The charset is latin1. The collation is latin1_swedish_ci.
Then php put the data on a web page. Now there is a problem, Swedish characters turns into garbage. This probably can be fixed in the php end, but I would prefer that MySQL took care of this. MySql knows the charset and the collation, so I am looking for some MySQL command that translates this into HTML before it leaves the MySQL server.
Then php put the data on a web page. Now there is a problem, Swedish characters turns into garbage. This probably can be fixed in the php end, but I would prefer that MySQL took care of this. MySql knows the charset and the collation, so I am looking for some MySQL command that translates this into HTML before it leaves the MySQL server.
a database is a data storage/calculation device, not a display device
it is up to the display device to show things the way things should be shown
just imagine internet explorer automatically displaying all languages in chinees
> trying to solve this in the database wouldn't get you anywhere
displaying is a matter of correctly translating
> the database has no clue what language is used in the display device
it is up to the display device to show things the way things should be shown
just imagine internet explorer automatically displaying all languages in chinees
> trying to solve this in the database wouldn't get you anywhere
displaying is a matter of correctly translating
> the database has no clue what language is used in the display device
ASKER
> the database has no clue what language is used in the display device
The database collation is set to "latin1_swedish_ci", so the database knows what language is used, the theoretical either a php or a mysql functon is used to encode this to html. I don't see any harm in the MySQL team add a function to encode into html, it might even make MySQL more popular. Something like:
HtmlEncoded Select * from TableAlfa where ....;
But when no such function exists, then il guess that PHP better take care of it.
The database collation is set to "latin1_swedish_ci", so the database knows what language is used, the theoretical either a php or a mysql functon is used to encode this to html. I don't see any harm in the MySQL team add a function to encode into html, it might even make MySQL more popular. Something like:
HtmlEncoded Select * from TableAlfa where ....;
But when no such function exists, then il guess that PHP better take care of it.
Actually I think it will harm the reputation of the MySQL team if they prioritize adding such a feature over other more needed fixes. Also, I doubt if it will be a popular feature, because the recommended practice is to decouple functionality, i.e. keep business/data logic and presentation logic separate. This will also allow you to easily customize presentation to different types of devices i.e. desktop vs mobile browsers.
Please also note that the display of international characters also depends on what the page tells the browser what character set the content uses and whether the browser can support it. This is clearly the business of presentation code.
Please also note that the display of international characters also depends on what the page tells the browser what character set the content uses and whether the browser can support it. This is clearly the business of presentation code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try iconv while sending data to php.
you have to install iconv module.
iconv("ISO-8859-1,"UTF-8" //TRANSLIT", $yourdata);
However best thing would be to try and mysql for UTF8 instead of latin1;
you have to install iconv module.
iconv("ISO-8859-1,"UTF-8" //TRANSLIT", $yourdata);
However best thing would be to try and mysql for UTF8 instead of latin1;
On the web page I think it is only a matter of setting the correct charset on the header. Something like Content-Type: text/plain; charset=ISO-8859-1