3

I developed a website in french language, and I am facing disorder in the french words for the country list. Can any one let me know what collation type should be used for french language for language's table?

Link : http://www.atlasanesp.mr/register.php
Please look at the dropdown with the title 'Pays de résidence'

msrd0
  • 7,816
  • 9
  • 47
  • 82
Haisum Usman
  • 518
  • 5
  • 13

3 Answers3

6

Just use UTF-8.

Add in the top of the HTML page:

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

and in the PHP page:

header('Content-type: text/html; charset=utf-8');

in your DB launch the query:

mysqli_query('SET CHARACTER SET utf8');

it should work!

Stewart
  • 3,935
  • 4
  • 27
  • 36
rvandoni
  • 3,297
  • 4
  • 32
  • 46
  • 2
    Note that the `mysql_*` functions are deprecated and will be removed from the language soon. – PeeHaa Sep 09 '14 at 08:20
  • 2
    I don't think this answers the question sufficiently. @haisum-usman is asking about the collation (i.e. the proper sorting), not the charset. – Michael Osl Sep 09 '14 at 08:38
4

Just always use UTF-8, for any language. But it's important to make sure your code is also in UTF-8. Check your PHP files and all other text files in the project.

UTF-8 is considered standard today. It's common newbie error to not use it, happens to people that speak non English language.

In MySQL it would be utf8_general_ci if you need your searches to be not case sensitive.

  • If we're talking about MySQL I'd recommend `utf8_general_ci` to be a little more precise. – Anticom Sep 09 '14 at 08:15
  • @Anticom `utf8_general_ci` is pretty much broken, use `utf8_unicode_ci` instead – PeeHaa Sep 09 '14 at 08:19
  • @PeeHaa Got any reference? I'm interested in what's broken in `utf8_general_ci`. – Anticom Sep 09 '14 at 08:24
  • @rikpg nothing changes,all same. I have defined the same characterset and content type which is placed below, And the table's collation is 'utf8_general_ci'. Please have a look at http://www.atlasanesp.mr/register.php title 'Pays de résidence' – Haisum Usman Sep 09 '14 at 08:27
3

After a long RND i found two things that needs to be used to handle different languages along with their special characters.

1- You need to define the collation of your table to be utf8_general_ci.

2- You need to define the 'mysql_set_charset('utf8');' in the file where you made connection with the database and right after the selection of database like 'mysql_select_db' use this 'mysql_set_charset' this will allow you to add and retrieve data properly in what ever the language it is.

I personally appreciate the answers given by my fellows and thanks to all.

Haisum Usman
  • 518
  • 5
  • 13