use word_filter::WordFilterBuilder;
let filter = WordFilterBuilder::new().words("ã").build();
assert_eq!(filter.censor("ã"), "*");
This fails, since "ã" is technically two characters, but visually appears to be one. The default functionality should be changed to censor with regard to graphemes instead of characters.
It may be easiest to wrap this together with #12, since expanding the configurability of censoring will make this easy to do for users. Alternatively, a separate value for CensorMode could be added. Something like ReplaceGraphemesWith.
The downside of supporting this is having to pull in a dependency like unicode_segmentation, increasing the dependency tree's size. It could work better as an optional feature or (#12 pending) a separate crate providing a Censor that supports grapheme replacement.
Consider the following example:
This fails, since
"ã"
is technically two characters, but visually appears to be one. The default functionality should be changed to censor with regard to graphemes instead of characters.It may be easiest to wrap this together with #12, since expanding the configurability of censoring will make this easy to do for users. Alternatively, a separate value for
CensorMode
could be added. Something likeReplaceGraphemesWith
.The downside of supporting this is having to pull in a dependency like
unicode_segmentation
, increasing the dependency tree's size. It could work better as an optional feature or (#12 pending) a separate crate providing aCensor
that supports grapheme replacement.