java COLLATE LOCALIZED ASC 代表什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2380706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 20:53:15  来源:igfitidea点击:

What does COLLATE LOCALIZED ASC stand for?

javaandroidsqlitecontactscontract

提问by Pentium10

private Cursor getContacts()
    {
        // Run query
        Uri uri = ContactsContract.Contacts.CONTENT_URI;
        String[] projection = new String[] {
                ContactsContract.Contacts._ID,
                ContactsContract.Contacts.DISPLAY_NAME
        };
        String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +
                (mShowInvisible ? "0" : "1") + "'";
        String[] selectionArgs = null;
        String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";

        return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
    }

What does COLLATE LOCALIZED ASCstand for?

代表什么COLLATE LOCALIZED ASC

回答by Kris

Collate is just fancy speak for sort (well sort of). So this is sort ordering based on localized preferences (i.e. current language's alphabet and conventions) in ascending order.

整理只是花哨的排序(很好)。所以这是基于本地化首选项(即当前语言的字母表和约定)以asc结束顺序进行排序。

回答by eric

It instructs SQLite to sort non-ASCII characters appropriately. Chars with diacritics (some call them accents) have higher byte codes than the character Z, so a plain ASCII sort wouldn't fit to many foreign languages.

它指示 SQLite 对非 ASCII 字符进行适当的排序。带有变音符号的字符(有些人称之为重音符号)比字符 Z 具有更高的字节码,因此普通的 ASCII 排序不适合许多外语。

For example, the capital A char's byte code is 0x41and the capital Z char's is 0x5A. Then we have the á (capital A accute) which code in Unicode is 0x00C1. So a plain byte code sort would result the á to be after the Z.

例如,大写的 A 字符的字节码是0x41,大写的 Z 字符的字节码是0x5A。然后我们有 á(大写 A accute),Unicode 中的代码是0x00C1。所以一个普通的字节码排序会导致 á 在 Z 之后。

But in languages that have this kind of characters the convention is to put those with diacritics as if they didn't have the diacritic. So the á should be together with the plain A, at least before B.

但是在具有这种字符的语言中,惯例是将那些带有变音符号的字符视为没有变音符。所以 á 应该与普通的 A 在一起,至少在 B 之前。

And to illustrate, we have below a list of names sorted using their bytecode:

为了说明,我们在下面列出了使用字节码排序的名称:

  • Brenda
  • Debby
  • George
  • álvaro
  • érico
  • 布伦达
  • 黛比
  • 乔治
  • 阿尔瓦罗
  • 埃里科

Now using the COLLATE LOCALIZEDit would sort by the "base" of the character:

现在使用COLLATE LOCALIZED它会按字符的“基数”排序:

  • álvaro
  • Brenda
  • Debby
  • érico
  • George
  • 阿尔瓦罗
  • 布伦达
  • 黛比
  • 埃里科
  • 乔治

回答by dan04

COLLATE is an SQL operator that lets you override the default sort order for strings. For example, "COLLATE NOCASE" does case-insensitive comparison, and "COLLATE BINARY" does a case-sensitive comparison.

COLLATE 是一个 SQL 运算符,可让您覆盖字符串的默认排序顺序。例如,“COLLATE NOCASE”进行不区分大小写的比较,而“COLLATE BINARY”进行区分大小写的比较。

The SQLite C interface lets you define custom collations (http://www.sqlite.org/c3ref/create_collation.html).

SQLite C 接口允许您定义自定义排序规则 ( http://www.sqlite.org/c3ref/create_collat​​ion.html)。