Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What kind of normalization is used by Swift string comparisons?

Elsewhere I've seen it told that Swift's comparisons use NFD normalization.

However, running in the iSwift playground I've found that

print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}");

gives false, despite this being an example straight from the standard of "Canonical Equivalence", which Swift's documentation claims to follow.

So, what kind of canonicalization is performed by Swift, and is this a bug?

like image 418
Veedrac Avatar asked Jan 31 '16 15:01

Veedrac


People also ask

What is data normalization and how does it work?

When Data Normalization is done correctly, standardized data entry is the result. This technique, for example, applies to the recording of URLs, contact names, street locations, phone numbers, and even codes. These standardized data fields can thus be quickly grouped and read.

How to check for string and character equality in Swift?

Sponsor sarunw.com and reach thousands of iOS developers. In Swift, you can check for string and character equality with the "equal to" operator ( ==) and "not equal to" operator ( != ). We use the same operator for Character. These "equal to" operator is suitable for simple string comparison where you required an exact match.

Is a normalized database good for referential integrity?

These anomalies are not good for referential integrity (or for data integrity in general). In a normalized database, the data is usually arranged independently of the users’ desired view of that data. This is one of the principles of relational database design.

What is a normalized database schema?

Here’s an example of a normalized database schema: A basic schema diagram of a normalized database. This schema separates the data into three different tables. Each table is quite specific in the data that it stores – there’s one table for albums, one for artists, and another that holds data that’s specific to genre.


1 Answers

It seems that this was in bug in Swift that has since been fixed. With Swift 3 and Xcode 8.0,

print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}")

now prints true.

like image 126
AthanasiusOfAlex Avatar answered Oct 31 '22 03:10

AthanasiusOfAlex