Casefold

Casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )
casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )

Description

The Casefold function returns a normalized string. When strings are transformed into their normalized forms, canonical-equivalent strings have precisely the same binary representation. Then, a binary comparison function such as equals can compare two strings for case-insensitive matching.

The Unicode Standard provides well-defined normalization forms (see Section 5.18, Case Mappings).

By default, Fauna uses NKFCCaseFold as recommended by the W3C, but provides NFKCCaseFold, NFC, NFD, NFKC, NFKD.

Parameters

Argument Type Definition and Requirements

value

String

A string to normalize.

normalizer

String

Optional - The name of the normalizer method to use. Must be one of "NFKCCaseFold", "NFC", "NFD", "NFKC", or "NFKD". Defaults to "NFKCCaseFold".

Returns

A string value.

Examples

The query below converts the string "Hen Wen" to "hen wen" to support case-insensitive matching.

client.Query(Casefold("Hen Wen"));
"hen wen"
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "casefold": "Hen Wen" }'
HTTP/1.1 200 OK
{ "resource": "hen wen" }
result, _ := client.Query(f.Casefold("Hen Wen"))

fmt.Println(result)
hen wen
System.out.println(
       client.query(Casefold(Value("Hen Wen")))
       .get());
"hen wen"
client.query(q.Casefold('Hen Wen'))
.then((ret) => console.log(ret))
hen wen
client.query(q.casefold("Hen Wen"))
"hen wen"
client.query(Casefold("Hen Wen"))
"hen wen"

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!