0

So I make web page where I use languages slovenian, italian, russan and engilsh on same page. This webpage comunicates with php script. Php script is dealing with mysql databse. So my question is how to deal with php, I suppose that html and mysql will work fine, but how to configure php. I have not try it yet.

HTML To get all the correct characters all languages on HTML page I use:

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

PHP To get all slovenina correct characters (specilly š,č,ž,Č,Ž,Š) I use at begging of the php script:

 setlocale ( LC_ALL, 'sl_SI.UTF-8' ); 
 $array = array (
    "c",
    "č",
    "s",
    "š",
    "z",
    "ž"
 );
 usort ( $array, 'strcoll' );

and to put data with php to mysql database I use before I make query: mysql_query("set names 'utf8'");

MYSQL DB In mysql in one table I will inesrt data writen in slovenina, english, russan and italy. So my table is declared as:

 utf8_general_ci

PROJECT I work in php eclispe and mz project uses text file encoding as UTF8.

My question is how to set local in PHP for russan, italian and english local and how to in mysql? Should I have for each language itself it's own colum and set for these colum apropriate language (as utf8_general_ci)? I hope you understand me!

  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) - note: the meta tag won't hurt but it's probably the most irrelevant bit. – Álvaro González Jan 08 '14 at 11:29
  • "Set locale" to do what exactly? What is the deficiency with the current setup (which sounds reasonable so far). – deceze Jan 08 '14 at 11:46
  • Whit setlocal I read values from input fildes from form wihich has č,š,ž in slovene language. So if I wodn't have this then I would have some symbols for č,š,ž. Do you now understand me? – IndexOutOfDevelopersException Jan 08 '14 at 12:02
  • Nope, not getting it. Don't confuse *encodings* with *locales*. You can create an app which supports all characters available to computers by, for example, using the UTF-8 *encoding* front to back without ever touching anything locale related. Locales are necessary for language-aware operations such as sorting, they are not necessary to just transport characters back and forth. – deceze Jan 08 '14 at 12:10
  • But when I have not this pice of code I coudn't recive apropriate č,š and ž in php script. When I was than it was working well. So I confuse some stuf. Hm. Can You maybe explain me more abouth this local? – IndexOutOfDevelopersException Jan 08 '14 at 12:12
  • 1
    First try to make your app handle encodings correctly: [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/). – deceze Jan 08 '14 at 14:09

0 Answers0