本文介绍了对使用非英文字体的记录进行排序的可能方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用Devnagari字体.键盘中的每个英文键代表Devnagari中的某些字符.例如,我的名字叫Sabin(英语),但是当我使用devnagari字体时,它是没有引号的; lag".记录以这种方式保存在数据库中.现在我在排序记录时遇到问题.

I m using Devnagari fonts in my application. Each English key in keyboard represent certain character in Devnagari. For example my name is Sabin in English but when i use devnagari font it would be ";lag" without quotes. And records are saved in this way in the database. Now i m having problem in sorting records.

首先在Devnagari中出现的是Devnagari元音,然后是Devnagari字母.喜欢c,cf,O,O {,p,pm,...... [每个用逗号分隔]然后从一开始就等同于devnagari字母,s,v,u,#,...等等[每个用逗号隔开].

In devnagari first comes are Devnagari vowels and then devnagari alphabets. Likec,cf,O,O{,p,pm,...... [each one separated by comma]Then devnagari alphabets equivalent starting from first,s,v,u,#,... and so on [each one separated by comma].

我遇到的问题是在devnagari中按字母顺序对名称进行排序.任何想法将不胜感激.谢谢!

Problem I m having is sorting names alphabetically in devnagari. Any idea will be highly appreciated. Thanks!

返回的数组如下,我需要使用usort函数.

The array returned as following which I need to use usort function.

Array
(
    [0] => stdClass Object
    (
        [user_id] => NLK32437
        [first_name] => ;lag
        [last_name] => %]qL
        [email_address] => [email protected]
        [mobile_number] => 9834874582
        [description] => g]kfn
        [date_joined] => 08-AUG-12
        [status] => 1
        [username] => user1
        [userpassword] => 691f9298642af07c2d6ea8fef56074201e077b34
    )

[1] => stdClass Object
    (
        [user_id] => NLK32435
        [first_name] => clgn
        [last_name] => zdf{
        [email_address] => [email protected]
        [mobile_number] => 984134354
        [description] => g]kfn
        [date_joined] => 08-AUG-12
        [status] => 1
        [username] => user2
        [userpassword] => 0e025eade868b4b481f41ff7449bc1967261e170
    )

)

推荐答案

您正在滥用文本编码.您将文本另存为用于其他目的的代码点,并且仅使用一种将原始英文字母呈现为其他字符的字体.这完全是错误的方法.

You are abusing text encodings. You are saving your text as codepoints that are meant for other things, and are only using a font that renders the originally English letters as something else. This is entirely the wrong way to go about it.

有几种编码可以将Devanagari保存为实际的Devanagari字符.它受Unicode支持.将文本另存为原意的梵文字符,不要使现有的英语代码点超载,并取决于损坏的字体.然后,您将通过支持Unicode的任何东西获得排序功能和许多其他功能.

There are several encodings which let you save Devanagari as actual Devanagari characters. It's supported in Unicode. Save the text as actual Devanagari characters that they were meant to be, don't overload existing English code points and depend on a broken font. Then you'll get sorting functionality and many other things by anything that supports Unicode.

尽管如此,一个简单的usort示例:

A simple usort example nonetheless:

usort($array, function ($a, $b) {
    static $order = array('M', 'A', ';', 'L', ...);
    return array_search($a, $order) - array_search($b, $order);
});

这篇关于对使用非英文字体的记录进行排序的可能方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 04:36