Symbian fold collate

Source: Internet
Author: User

1. tdesc findf, comparef, matchf
Folding means treating upper and lower case characters the same. folding is used in the file system to determine if two file names are equivalent. folding never depends on which locale is current. folding is not suitable for determining if two strings wocould be considered equivalent by the user; that is what Collation is!

Note that functions that "fold a character" or "fold a string" originally changed all letters to lower case, the assumption being that if you uppercased every letter in two strings and binary-Compared them you wowould have the same result as comparef. because in Unicode you also need to put them into canonical form this assumption no longer holds, so anyone using fold () or collate () is almost certain Ly doing something wrong!

2. 4 level collation, tdesc comparec, matchc, findc
Collation is a method of comparing two strings, to see which wocould be sorted first or to test for equality. collation is locale-dependent; different cultures sort the same strings in different orders. in some cases different cultures may have different ideas about how equivalent two strings are. for example:

English sorting:

Tan <tap <t? P <tar <ten

Finnish sorting

Tan <tap <tar <ten <t? P

There are a few things to notice here:
1) Although capital letters are heavier (sort later) than small letters, difference in case does not matter as much as difference in accents, even when the difference in case happens earlier in the string.
2) even though "? "Character is heavier than the unadorned" A "in the English sort, this difference does not matter as much as a difference in the basic letters, even when the accent difference happens earlier in the string.
3) in the Finnish sort, "? "Character is heavier than E; the accent is now as important as a letter difference.

In order to get this subtlety of behaviour, the collation algorithm defines four "levels": Level 0 is basic character identity (A, B, C are different but a, ,? Are all equivalent ). level 1 is accents. level 2 is case. level 3 is everything else (for example R and the mathematical real number set are the same at levels 0, 1 and 2 ).

Strings that differ at level 0 are sorted according to their earliest level 0 difference. strings that differ at level 1 but not level 0 are sorted according to their level 1 difference. strings that differ at Level 2 but not levels 0 and 1 are sorted according to their level 2 difference. strings that match at levels 0, 1 and 2 are sorted according to their earliest level 3 difference.

This behaviour means that a developer does not have to choose between ignoring case (which wowould sort "tap" and "tap" arbitrarily) and enforcing case (which wowould sort "tap" ahead of "Tan") and similarly with accents. the result is usually just what you want.

The Locale can supply a "tailoring" table, that changes the hard-coded basic table by introducing more keys or changing existing weights, such as in the Finnish example above.

Some characters are marked as "ignorable", these are spaces and punctuation and other such characters. by default these are ignored at levels 0, 1 and 2 during matching, but taken into account during collation. the options for collation can be altered for comparec by supplying a different collation method:

// Get collation table used by comparec (DES); the value returned doesn't change into T perhaps at boot time
Tcollationmethod M = * mem: getcollationmethodbyindex (0 );
// Or use * mem: getdefaultmatchingtable () for matching functions
// Or use textendedlocale: getpreferredcollationmethod (); this gets you the latest value set
M. iflags | = tcollationmethod: eignorenone; // set that punctuation and spaces are important at level 0
Des16.comparec (otherdes, level, M );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.