diff options
| author | 2025-03-25 00:37:56 +0300 | |
|---|---|---|
| committer | 2025-04-29 12:30:55 -0400 | |
| commit | 98230529072f8923daf396eeb70ea108eaa2590c (patch) | |
| tree | fd15d84199a3873016d99c0901a704169e11357a | |
| parent | All the std.mem.Allocators that were stored just for init and deinit (diff) | |
| download | zg-98230529072f8923daf396eeb70ea108eaa2590c.tar.gz zg-98230529072f8923daf396eeb70ea108eaa2590c.tar.xz zg-98230529072f8923daf396eeb70ea108eaa2590c.zip | |
README.md was updated to reflect last changes in API.
| -rw-r--r-- | README.md | 26 |
1 files changed, 13 insertions, 13 deletions
| @@ -93,7 +93,7 @@ const grapheme = @import("grapheme"); | |||
| 93 | test "Grapheme cluster iterator" { | 93 | test "Grapheme cluster iterator" { |
| 94 | // we need some Unicode data to process Grapheme Clusters. | 94 | // we need some Unicode data to process Grapheme Clusters. |
| 95 | const gd = try grapheme.GraphemeData.init(allocator); | 95 | const gd = try grapheme.GraphemeData.init(allocator); |
| 96 | defer gd.deinit(); | 96 | defer gd.deinit(allocator); |
| 97 | 97 | ||
| 98 | const str = "He\u{301}"; // Hé | 98 | const str = "He\u{301}"; // Hé |
| 99 | var iter = grapheme.Iterator.init(str, &gd); | 99 | var iter = grapheme.Iterator.init(str, &gd); |
| @@ -138,7 +138,7 @@ const GenCatData = @import("GenCatData"); | |||
| 138 | 138 | ||
| 139 | test "General Category" { | 139 | test "General Category" { |
| 140 | const gcd = try GenCatData.init(allocator); | 140 | const gcd = try GenCatData.init(allocator); |
| 141 | defer gcd.deinit(); | 141 | defer gcd.deinit(allocator); |
| 142 | 142 | ||
| 143 | // The `gc` method returns the abbreviated General Category. | 143 | // The `gc` method returns the abbreviated General Category. |
| 144 | // These abbreviations and descriptive comments can be found | 144 | // These abbreviations and descriptive comments can be found |
| @@ -176,7 +176,7 @@ const PropsData = @import("PropsData"); | |||
| 176 | 176 | ||
| 177 | test "Properties" { | 177 | test "Properties" { |
| 178 | const pd = try PropsData.init(allocator); | 178 | const pd = try PropsData.init(allocator); |
| 179 | defer pd.deinit(); | 179 | defer pd.deinit(allocator); |
| 180 | 180 | ||
| 181 | // Mathematical symbols and letters. | 181 | // Mathematical symbols and letters. |
| 182 | try expect(pd.isMath('+')); | 182 | try expect(pd.isMath('+')); |
| @@ -230,7 +230,7 @@ const CaseData = @import("CaseData"); | |||
| 230 | 230 | ||
| 231 | test "Case" { | 231 | test "Case" { |
| 232 | const cd = try CaseData.init(allocator); | 232 | const cd = try CaseData.init(allocator); |
| 233 | defer cd.deinit(); | 233 | defer cd.deinit(allocator); |
| 234 | 234 | ||
| 235 | // Upper and lower case. | 235 | // Upper and lower case. |
| 236 | try expect(cd.isUpper('A')); | 236 | try expect(cd.isUpper('A')); |
| @@ -295,29 +295,29 @@ test "Normalization" { | |||
| 295 | // We need lots of Unicode dta for normalization. | 295 | // We need lots of Unicode dta for normalization. |
| 296 | var norm_data: Normalize.NormData = undefined; | 296 | var norm_data: Normalize.NormData = undefined; |
| 297 | try Normalize.NormData.init(&norm_data, allocator); | 297 | try Normalize.NormData.init(&norm_data, allocator); |
| 298 | defer norm_data.deinit(); | 298 | defer norm_data.deinit(allocator); |
| 299 | 299 | ||
| 300 | // The `Normalize` structure takes a pointer to the data. | 300 | // The `Normalize` structure takes a pointer to the data. |
| 301 | const n = Normalize{ .norm_data = &norm_data }; | 301 | const n = Normalize{ .norm_data = &norm_data }; |
| 302 | 302 | ||
| 303 | // NFC: Canonical composition | 303 | // NFC: Canonical composition |
| 304 | const nfc_result = try n.nfc(allocator, "Complex char: \u{3D2}\u{301}"); | 304 | const nfc_result = try n.nfc(allocator, "Complex char: \u{3D2}\u{301}"); |
| 305 | defer nfc_result.deinit(); | 305 | defer nfc_result.deinit(allocator); |
| 306 | try expectEqualStrings("Complex char: \u{3D3}", nfc_result.slice); | 306 | try expectEqualStrings("Complex char: \u{3D3}", nfc_result.slice); |
| 307 | 307 | ||
| 308 | // NFKC: Compatibility composition | 308 | // NFKC: Compatibility composition |
| 309 | const nfkc_result = try n.nfkc(allocator, "Complex char: \u{03A5}\u{0301}"); | 309 | const nfkc_result = try n.nfkc(allocator, "Complex char: \u{03A5}\u{0301}"); |
| 310 | defer nfkc_result.deinit(); | 310 | defer nfkc_result.deinit(allocator); |
| 311 | try expectEqualStrings("Complex char: \u{038E}", nfkc_result.slice); | 311 | try expectEqualStrings("Complex char: \u{038E}", nfkc_result.slice); |
| 312 | 312 | ||
| 313 | // NFD: Canonical decomposition | 313 | // NFD: Canonical decomposition |
| 314 | const nfd_result = try n.nfd(allocator, "Héllo World! \u{3d3}"); | 314 | const nfd_result = try n.nfd(allocator, "Héllo World! \u{3d3}"); |
| 315 | defer nfd_result.deinit(); | 315 | defer nfd_result.deinit(allocator); |
| 316 | try expectEqualStrings("He\u{301}llo World! \u{3d2}\u{301}", nfd_result.slice); | 316 | try expectEqualStrings("He\u{301}llo World! \u{3d2}\u{301}", nfd_result.slice); |
| 317 | 317 | ||
| 318 | // NFKD: Compatibility decomposition | 318 | // NFKD: Compatibility decomposition |
| 319 | const nfkd_result = try n.nfkd(allocator, "Héllo World! \u{3d3}"); | 319 | const nfkd_result = try n.nfkd(allocator, "Héllo World! \u{3d3}"); |
| 320 | defer nfkd_result.deinit(); | 320 | defer nfkd_result.deinit(allocator); |
| 321 | try expectEqualStrings("He\u{301}llo World! \u{3a5}\u{301}", nfkd_result.slice); | 321 | try expectEqualStrings("He\u{301}llo World! \u{3a5}\u{301}", nfkd_result.slice); |
| 322 | 322 | ||
| 323 | // Test for equality of two strings after normalizing to NFC. | 323 | // Test for equality of two strings after normalizing to NFC. |
| @@ -350,12 +350,12 @@ test "Caseless matching" { | |||
| 350 | // We need to normalize during the matching process. | 350 | // We need to normalize during the matching process. |
| 351 | var norm_data: Normalize.NormData = undefined; | 351 | var norm_data: Normalize.NormData = undefined; |
| 352 | try Normalize.NormData.init(&norm_data, allocator); | 352 | try Normalize.NormData.init(&norm_data, allocator); |
| 353 | defer norm_data.deinit(); | 353 | defer norm_data.deinit(allocator); |
| 354 | const n = Normalize{ .norm_data = &norm_data }; | 354 | const n = Normalize{ .norm_data = &norm_data }; |
| 355 | 355 | ||
| 356 | // We need Unicode case fold data. | 356 | // We need Unicode case fold data. |
| 357 | const cfd = try CaseFold.FoldData.init(allocator); | 357 | const cfd = try CaseFold.FoldData.init(allocator); |
| 358 | defer cfd.deinit(); | 358 | defer cfd.deinit(allocator); |
| 359 | 359 | ||
| 360 | // The `CaseFold` structure takes a pointer to the data. | 360 | // The `CaseFold` structure takes a pointer to the data. |
| 361 | const cf = CaseFold{ .fold_data = &cfd }; | 361 | const cf = CaseFold{ .fold_data = &cfd }; |
| @@ -399,7 +399,7 @@ const DisplayWidth = @import("DisplayWidth"); | |||
| 399 | test "Display width" { | 399 | test "Display width" { |
| 400 | // We need Unicode data for display width calculation. | 400 | // We need Unicode data for display width calculation. |
| 401 | const dwd = try DisplayWidth.DisplayWidthData.init(allocator); | 401 | const dwd = try DisplayWidth.DisplayWidthData.init(allocator); |
| 402 | defer dwd.deinit(); | 402 | defer dwd.deinit(allocator); |
| 403 | 403 | ||
| 404 | // The `DisplayWidth` structure takes a pointer to the data. | 404 | // The `DisplayWidth` structure takes a pointer to the data. |
| 405 | const dw = DisplayWidth{ .data = &dwd }; | 405 | const dw = DisplayWidth{ .data = &dwd }; |
| @@ -472,7 +472,7 @@ const ScriptsData = @import("ScriptsData"); | |||
| 472 | 472 | ||
| 473 | test "Scripts" { | 473 | test "Scripts" { |
| 474 | const sd = try ScriptsData.init(allocator); | 474 | const sd = try ScriptsData.init(allocator); |
| 475 | defer sd.deinit(); | 475 | defer sd.deinit(allocator); |
| 476 | 476 | ||
| 477 | // To see the full list of Scripts, look at the | 477 | // To see the full list of Scripts, look at the |
| 478 | // `src/ScriptsData.zig` file. They are list in an enum. | 478 | // `src/ScriptsData.zig` file. They are list in an enum. |