Commit Graph

63 Commits

Author SHA1 Message Date
Manish Goregaokar 4621ed6b98 Reset stream safe iterator to buffered character when outputting CGJ 2020-11-17 19:39:16 -08:00
Pyfisch bd1fcfbfab Update to Unicode 13
Change version fields to u8 as the maximum value
of each field is 255 according to specification.
2020-04-13 11:58:40 +02:00
Hannes Karppila 1d77ba2bc4 Add no_std + alloc support 2020-04-10 23:37:38 +03:00
Hannes Karppila ca0037583e Apply rustfmt 2020-04-10 23:37:34 +03:00
Hannes Karppila b098399338 Do not automatically format tables 2020-04-10 23:35:20 +03:00
Hannes Karppila 36184100f7 Remove ignored inline annotations 2020-04-10 23:35:19 +03:00
Hannes Karppila 0d6e296cc4 Migrate to Rust 2018 edition 2020-04-09 19:10:25 +03:00
Sergey "Shnatsel" Davidoff 432074711b Improve comment 2020-03-16 00:37:04 +01:00
Sergey "Shnatsel" Davidoff 09fdcc2b81 Switch from SmallVec to 100% safe TinyVec 2020-01-13 19:56:13 +01:00
Kent Fredric beab8d66a0 Move "normalization" test data and dependent tests all into tests/
Leaves all other tests in place.

Provides a #[doc(hidden)] shim for accessing/using otherwise private
members from tests/
2019-11-20 03:57:38 +13:00
Kamat, Trivikram e1c602752f Allows ellipsis_inclusive_range_patterns
Refs: https://github.com/unicode-rs/unicode-normalization/issues/41
2019-10-13 12:42:06 -07:00
Raph Levien a6db7c0256 Move lookups into own module 2019-04-16 10:56:44 -07:00
Raph Levien 9aacd59532 Move code out of tables
The code has been moved out of the tables module into perfect_hash, and
there is a bit more explanation in comments.
2019-04-16 10:42:11 -07:00
Raph Levien 93d8afb900 Use perfect hashing for compose lookup 2019-04-09 17:51:03 -07:00
Raph Levien df37994166 Use perfect hashing for decomposition also 2019-04-09 17:20:27 -07:00
Raph Levien b68dbec11f More lookups moved to perfect hashing 2019-04-09 16:46:28 -07:00
Raph Levien 274b267525 Use minimal perfect hashing for combining class lookup 2019-04-09 12:26:24 -07:00
Sujay Jayakar 35cc77d8ad Bump version to 0.1.8 2019-01-21 13:02:48 -08:00
Sujay Jayakar d9e05260c6 Merge branch 'master' into smallvec 2019-01-21 11:22:08 -08:00
David Judd b114982681 Add comment 2019-01-17 08:41:47 -08:00
David Judd c6524d31d4 Use fuse 2019-01-17 08:28:15 -08:00
David Judd cc81a58409 Revert "restore done field to Decompositions"
This reverts commit 099fef3b72.
2019-01-17 08:25:11 -08:00
David Judd 099fef3b72 restore done field to Decompositions 2019-01-15 21:31:18 -08:00
Sujay Jayakar e03d61cce8 Merge pull request #36 from djudd/compatibility-quick-checks
Add quick check implementations for NFKC & NFKD
2019-01-14 22:40:37 +05:30
David Judd 5685166427 Add quick check implementations for NFKC & NFKD 2019-01-12 14:44:53 -08:00
David Judd 70741bd31d Use SmallVec in place of VecDeque in recompose 2019-01-12 11:01:54 -08:00
David Judd 29e7a0ba40 Use SmallVec in place of Vec in decompose & avoid remove(0) 2019-01-12 11:01:22 -08:00
David Judd 79e9942f2a Add smallvec 2019-01-12 10:59:23 -08:00
Björn Steinbrink 41914c5d30 Generate code that is friendlier to rustc's item_bodies_checking
Having the Some() constructor in each match arm body puts extras stress
on rustc's item_bodies_checking pass. We can work around that by moving
the Some() constructor around the match, and directly returning None
from the default arm, which is the only one that generates a None value.

On my box, this almost cuts the time spent in item_bodies_checking in
half, going from about 8.7s to about 4.6s, and reduces the complete
compile time from about 13s to about 9s, so about a third less.

There are no changes in performance in `cargo bench`.

Note that doing the same for the composition_table() function does not
yield any compile time wins, but would cause a performance regression.

cc #29
2019-01-08 17:02:41 +01:00
Sujay Jayakar 7389eb31f1 Bump version (and update docs) 2018-05-09 12:39:23 -07:00
Sujay Jayakar ef9a4dd691 Implement Stream-Safe QuickCheck variant 2018-05-07 20:55:59 -07:00
Sujay Jayakar ef810e3380 Update range naming 2018-05-07 20:02:04 -07:00
Sujay Jayakar 3156992b87 Factor out T_START from match statement 2018-05-07 19:14:55 -07:00
Sujay Jayakar 9f6cc853cc Fix corner case in Hangul composition 2018-05-07 15:34:22 -07:00
Sujay Jayakar 4d7e81e0ab Add Stream-Safe Text Process (for interop with golang's unicode/norm package) 2018-05-01 21:43:04 -07:00
Sujay Jayakar 6a7e38e376 Refactor Unicode script, emit new tables, and add QuickCheck algorithm. 2018-05-01 21:00:38 -07:00
Sujay Jayakar 4d76b961b8 Remove unnecessary unwrap in recompose 2018-04-27 13:37:29 +05:30
Sujay Jayakar 74dddd6f8d Remote unnecessary transmute (in favor of char::from_u32_unchecked) 2018-04-27 13:37:20 +05:30
Sujay Jayakar 0e821ff949 Simplify decomposition
- Eliminate custom sorter
  - Only sort the "pending" suffix of the buffer
2018-04-27 13:37:16 +05:30
Behnam Esfahbod 1e74c347b6 Fix is_combining_mark table data
* In `scripts/unicode.py`, the data used to generate `is_combining_mark()`
was being passed to the emit function incorrectly, resulting in the
table containing some other data instead. The script is fixed and new
`tables.rs` is generated.

* Add test for `is_combining_mark()` for ASCII chars, as well as a
couple of random chars based on the reported issue.

Fix https://github.com/unicode-rs/unicode-normalization/issues/16
2017-06-01 15:10:29 -06:00
Simon Sapin 3898e77b11 Merge pull request #14 from froydnj/trim-unicode-tables
reduce space required by decomposition and composition tables
2017-04-12 17:11:46 +08:00
Nathan Froyd 8d01bc5e88 store smaller slices in unicode data tables
Rust's default slices are convenient, but for tables like:

  const f: &'static [(char, &'static [char])]

they take up far too much space.  An element of the above array consumes
24 bytes on 64-bit platforms, and unicode-normalization contains about
6000 such array elements.

A better approach is to manually store a smaller slice type:

  struct Slice {
    offset: u16,
    length: u16,
  }

  const f: &'static [(char, Slice)]

and store the actual character data in a separate array on the side.
The `Slice` structures then point in to this separate array, but at a
much smaller space cost: elements of the modified `f` take up only 8
bytes on 64-bit platforms, which implies a space savings of ~96K on
64-bit platforms.  On some systems, this strategy also eliminates the
necessity of run-time relocations, which can be a further, significant
savings in binary size and runtime cost.

This change is strictly local to the library; it does not affect the
public API.
2017-03-27 16:58:31 -04:00
Nathan Froyd 7552e6cd2b format tables with one entry per line
This change avoids formatting table entries into a string, only to split
them apart again.  The new format is also slightly easier to read and
compare when changes are made to how the tables are organized.
2017-03-27 15:13:36 -04:00
Clar Charr 2d5988475c Implement Display for Recompositions, Decompositions. 2017-01-16 16:37:01 -05:00
kwantam 7625142dee update version numbers in README and lib.rs comments 2016-12-23 15:47:20 -08:00
Simon Sapin 7299191fce Update to Unicode 9.0.0 2016-12-20 00:03:22 +01:00
Manish Goregaokar e4fd0e1b21 Do not further compose LVT hangul precomposed syllable blocks
Fix #11.

The algorithm for composition of Hangul Jamo is:

 - L (choseong jamo) + V (jungseong jamo) = LV (syllable block)
 - LV (syllable block) + T (jongseong jamo) = LVT (syllable block)

However, the LV and LVT syllable blocks are intermingled in the unicode
block. In particular, for each pair LV, you will first see the syllable block
LV, followed by syllable blocks for LVT for each T. The LV+T
composition was a simple addition of offsets.

Our algorithm did not ignore the LVT syllable blocks, which meant that
LVT+T would just offset further and produce an unrelated syllable block.

By ensuring that the `S_index` is a multiple of `T_count`, we filter
for only LV syllable blocks (which occur every `T_count` codepoints in
the S block)
2016-12-20 00:03:14 +01:00
Simon Sapin 5d0443bd92 Add a char::is_combining_mark function.
This is used for international domain name validation:
http://unicode.org/reports/tr46/#Validity_Criteria

> The label must not begin with a combining mark, that is: General_Category=Mark.
2016-01-15 17:49:39 +01:00
Florian Zeitz 5f26506035 Update to Unicode 8.0.0 2015-07-08 12:46:46 +02:00
kwantam 3cc8effc71 bump version to 0.1.0 2015-04-21 13:56:25 -04:00