Q:encoding practices...best solution

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Q:encoding practices...best solution

Post by jmut »

Hi,
PHP 4.4* and above
MySQL 4.0.*

As far as I understand if using UTF8 encoding we could represent pretty much any language.
My question is how should one set his or her application to have no encoding problems.
I guess there are two parts of the problem:
Data encoding when stored in the database
Data encodig when presented on the web (charset=........).
I have no idea as to what part PHP plays in this.

Why nowadays someone would want to use something different from UTF encoding - even if representing one language in the time(one never knows).

Could I set MySQL 4.0* to use store (not sure if needs actually) data in UTF and then present it.

If someone knows any good article on this issue - I have real trouble with multilanguage stuff - as far as I see stuff, everything should be UTF encoded - but how exactly to implement is another question.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Any comments on this....
I am sure there are some of you very familiar with multilingual sites...using UTF etc.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You can use utf8_encode and utf8_encode for input and output of data in UTF-8.

If you are also using different encodings, iconv functions become handy. Or you can use the multibyte string extension.

And offcourse you need to use tell your users they are recieving utf-8

Code: Select all

<?php
header("Content-type: text/html; charset=utf-8");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
...
Post Reply