字符“ي"和“ی"和波斯语的区别-MySQL [英] Characters "ي" and "ی" and the difference in persian - Mysql

查看:1406
本文介绍了字符“ي"和“ی"和波斯语的区别-MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用集成了mysql数据库的UTF-8波斯语网站.网站上的所有内容都是通过管理面板导入的,都是波斯语.

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.

因此,如果有人搜索بازی",则mysql不会找到بازي".

So if a person searches for 'بازی' the mysql won't find 'بازي' as the result.

重要说明:'ی'不是唯一具有此属性的字符,它们很多而且非常相似.

如何解决此问题?

一个简单的幼稚解决方案似乎是在将数据导入数据库之前将所有ي"替换为ی",但是我正在寻找一个比此更好的健壮解决方案.

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.

推荐答案

尊敬的EBAG:我们有一个 Unicode 块,其中包含 Unicode ,同时包含阿拉伯语& 波斯语字符.

Dear EBAG, We have a single Arabic block in Unicode which contains both Arabic & Persian characters.

06CC 是波斯语ی 064A 是阿拉伯语ي

06CC is Persian ی and 064A is Arabic ي

默认Windows键盘使用code page 1256表示阿拉伯字符,这对于波斯和阿拉伯用户都将064A设置为默认ي,因为阿拉伯用户比波斯人要多得多.

Default windows keyboard uses code page 1256 for arabic characters which put 064A as default ي for bothPersian and Arab users because Arab users are much more than Persian.

ISIRI制作标准键盘ISIRI 9147,并在其上放置阿拉伯语和波斯语Yeh,但Perisan ی是默认字符.使用标准键盘的波斯用户将放置(并使用)标准波斯ی‍ while the rest of them use arabicي`.

ISIRI make an standard keyboard ISIRI 9147 and put both Arabic and Persian Yeh on 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.

第二种方法是在Web应用程序中使用JavaScript文件来控制用户输入.大多数波斯网站都使用这种方法将字符保存到数据库中.在这种方法中,用户不需要为波斯或阿拉伯语键盘安装任何键盘布局.他/她只是将键盘放在English上,然后在JavaScript文件开发人员中检查哪个字符对他来说是等效的. 此处,您可以找到用于Web应用程序的ISIRI 9147 javascript和使用它的波斯语向导.

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 English and then in JavaScript file developer check that which character is equevalent for him. Here you can find ISIRI 9147 javascript for 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.

第四种方法是搜索两种方言.如您所知,安装MySqlSQL Server时可以设置 collation ,并且还可以选择支持方言(并区分大小写).如果您启用带有方言的阿拉伯语排序规则,则可以同时获得它们的结果,通常在sql server中可以正常工作,我没有在MySql中对其进行测试.这是迄今为止最好的解决方案.

The forth approach is to search both dialect. As you know when you install MySql or SQL Server you can set the collation and 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 in sql server I don't test it in MySql. This is the best solution yet.

但是如果我是您,我将实现一个简单的sql function,该获取nvarchar并返回nvarchar.然后在我想写数据时调用它.而且每当您想阅读时,都可以去读一本标准书.

but if I were you, I implement a simple sql function which get nvarchar and return nvarchar. then I call it when I wanted to write data. and whenever you want to read, you can go for the standard one.

抱歉,长尾巴.

这篇关于字符“ي"和“ی"和波斯语的区别-MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆