Is there a way to do culturally sensitive equality comparisons?

I was doing some self-study on DAML and was trying to evaluate if DAML supports unicode characters. I saw in a different question this is supposed to be supported.

But when I ran the following DAML script this returned False:

-- [241] and [100, 771] both represent the Spanish character 'ñ', but
-- one uses a Unicode combining diacritic mark and the other does not
DA.Text.fromCodePoints [100, 771] == DA.Text.fromCodePoints [241]

I assume this returned False because the comparison was done purely byte-by-byte with UTF-8 encoding.

However having two different representations for the same grapheme is pretty common in languages that have ‘accents’ in letters like French and Spanish so I am wondering is there a way to specify these kinds of culturally sensitive equality comparisons.

Specifically is there a way to specify the Unicode Normalization Forms used to control the equality logic?

Not at the moment, no.

Generally speaking, the Daml ledger is there to record agreements, not to perform computations. Exactly where to put the separating line between those will vary per application, but, at the moment, given the state (completeness & performance) of the Daml Text libraries, string manipulation is a good candidate to push back to the clients.

1 Like