1SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset 2\if :skip_test 3\quit 4\endif 5SELECT U&'\0061\0308bc' <> U&'\00E4bc' COLLATE "C" AS sanity_check; 6 sanity_check 7-------------- 8 t 9(1 row) 10 11SELECT normalize(U&'\0061\0308\24D1c') = U&'\00E4\24D1c' COLLATE "C" AS test_default; 12 test_default 13-------------- 14 t 15(1 row) 16 17SELECT normalize(U&'\0061\0308\24D1c', NFC) = U&'\00E4\24D1c' COLLATE "C" AS test_nfc; 18 test_nfc 19---------- 20 t 21(1 row) 22 23SELECT normalize(U&'\00E4bc', NFC) = U&'\00E4bc' COLLATE "C" AS test_nfc_idem; 24 test_nfc_idem 25--------------- 26 t 27(1 row) 28 29SELECT normalize(U&'\00E4\24D1c', NFD) = U&'\0061\0308\24D1c' COLLATE "C" AS test_nfd; 30 test_nfd 31---------- 32 t 33(1 row) 34 35SELECT normalize(U&'\0061\0308\24D1c', NFKC) = U&'\00E4bc' COLLATE "C" AS test_nfkc; 36 test_nfkc 37----------- 38 t 39(1 row) 40 41SELECT normalize(U&'\00E4\24D1c', NFKD) = U&'\0061\0308bc' COLLATE "C" AS test_nfkd; 42 test_nfkd 43----------- 44 t 45(1 row) 46 47SELECT "normalize"('abc', 'def'); -- run-time error 48ERROR: invalid normalization form: def 49SELECT U&'\00E4\24D1c' IS NORMALIZED AS test_default; 50 test_default 51-------------- 52 t 53(1 row) 54 55SELECT U&'\00E4\24D1c' IS NFC NORMALIZED AS test_nfc; 56 test_nfc 57---------- 58 t 59(1 row) 60 61SELECT num, val, 62 val IS NFC NORMALIZED AS NFC, 63 val IS NFD NORMALIZED AS NFD, 64 val IS NFKC NORMALIZED AS NFKC, 65 val IS NFKD NORMALIZED AS NFKD 66FROM 67 (VALUES (1, U&'\00E4bc'), 68 (2, U&'\0061\0308bc'), 69 (3, U&'\00E4\24D1c'), 70 (4, U&'\0061\0308\24D1c')) vals (num, val) 71ORDER BY num; 72 num | val | nfc | nfd | nfkc | nfkd 73-----+-----+-----+-----+------+------ 74 1 | äbc | t | f | t | f 75 2 | äbc | f | t | f | t 76 3 | äⓑc | t | f | f | f 77 4 | äⓑc | f | t | f | f 78(4 rows) 79 80SELECT is_normalized('abc', 'def'); -- run-time error 81ERROR: invalid normalization form: def 82