2uzhan.com
Advertisement
Now Place:2uzhan.com » Cyrillic (Macedonian) and English in mysql database

Cyrillic (Macedonian) and English in mysql database

MySQL @ March 7, 2010   Views:0

I've been reading through forums for the past week about using mysql with cyrillic languages. My server runs mysql 5.1.

I wrote an online application for a camp, its in both english and macedonian as I expect to have some boys apply in their native language. This is my first foray into PHP and mysql.
When I set up the db originally, it has latin1_swedish collation and each element is also set to this collation. We have about 12 applications so far, half of which are in Macedonian, so I get input that looks like this Лазар in the database.

Here are my questions I could use some help with:

1. How do I set up the database correctly to handle both english and macedonian entries?

2. Will I have to add changes to my php code to make sure this input is handled correctly? I've read about adding SET NAMES in, but I really didn't understand how that works and whether I need this if I'm not retrieving data via website.

3. Can I resurrect the garbled data that has been received already and have it show up correctly if transferred to a db that is set up properly?

--------------Solutions-------------

Hi

Cyrillic charset is placed inside ascii range so I think cyrillc data can be recovered.
Ugly text you get is because data is converted from cyrillic to unicode utf-8 charset.
You can use set names command after line where you make db connection
set names command is passed in query like this "SET NAMES CP1251". cp1251 is bulgarian charset so you will need to replace it with macedonian charset

example of using set names

$link = mysql_connect($server, $db_user, $db_pass)
mysql_query("SET NAMES CP1251"); //cp1251 to set to bulgarian

I have no idea what are you doing but I would set everithing to macedonian cyrillic charset:
-php files encoding
-php default charset must be unset of you use html headers to set charset. If you do not want to set page charset with headers then you may want to set default charset to macedonian
-mysql db, tables and text fields
-mysql connection with set names

To set php.ini settings without to edit php.ini use ini_set php command in the begining of php code on each page

Of course if you want you can set db to utf-8 and then to use set names to convert to macedonian if you do not want to process data as unicode. If there is not problem for you with utf-8 you can entireluy use utf-8 (for storing and processing)

-------------------------------Signature-----------------------------------------
http://www.nezavisim.com
I need job so if in your company there is need for optimizing and improving I am the man.
I can work from home via internet. Results are always best

I can complete all tasks from idea to final product, handling hardware desing, programming, installing and configuring all required hadrware and software.
And what can you?

Forum Moderators delete my posts so I cannot write delailed explanations, becaue this will be waste of time when my post is deleted by motherators

Edited 2 time(s). Last edit at 03/08/2010 12:46PM by Ventsislav Alexandriyski.

Tags:
© 2018 2uzhan.com Contact