I’m working on a UTF-8 Persian website with integrated mysql database. All the content in the website are imported through an admin panel and it’s all persian.
As you might know arabic language has the same letters as persian except some.
The problem is when a person tries to type on a keyboard with arabic layout it writes “ي” as an character and if he tries to type by a keyboard with persian layout it types “ی” as character.
So if a person searches for ‘بازی’ the mysql won’t find ‘بازي’ as the result.
Important Note: ‘ی’ is not the only character with this property, there are lots of them and they are very similar.
How can I fix this issue?
One simple naive solution seems to be replace all “ي” with “ی” before importing the data into database, but i’m searching for a better robust solution than this.
Dear EBAG, We have a single Arabic block in Unicode which contains both Arabic & Persian characters.
06CC is Persian
یand 064A is ArabicيDefault windows keyboard uses
code page 1256for arabic characters which put064Aas defaultيfor bothPersian and Arab users because Arab users are much more than Persian.ISIRImake an standard keyboardISIRI 9147and put both Arabic and PersianYehon it but Perisanیis the default characters. Persian users which are using standard keyboard will put ( and use ) standard Persianی while the rest of them use arabicي`.As you told usually while we are saving a data to database we change arabic
يto Persianیand when we are reading from it we just go for Persian so everything is true.the second approach is to use a JavaScript file in web application to control user input. most of the persian websites use this approach to save characters to database. In this method user don’t need to install any Keyboard layout for Persian or Arabic keyboard. He/she just put the keyboard on
Englishand then inJavaScriptfile developer check that which character is equevalent for him. Here you can findISIRI 9147 javascriptfor web application and a Persian Guid to use it.the Third approach is to use a On-Screen Keyboard that work just like the previous one with a user interface and is usually good for thise who are not familiar with Persian keyboard.
The forth approach is to search both dialect. As you know when you install
MySqlorSQL Serveryou can set thecollationand also you have an option to support dialect ( and case sensivity). if you enable arabic collation with dialect you can get result for both of them and usually this works fine insql serverI don’t test it inMySql. This is the best solution yet.but if I were you, I implement a simple
sql functionwhich getnvarcharand returnnvarchar. then I call it when I wanted to write data. and whenever you want to read, you can go for the standard one.Sorry for the long tail.