Crate superfold

Source
Expand description

§superfold

A multilingual Rust library to process UTF-8 strings by excluding diacritics and folding non-phonetic graphemes into their phonetic ASCII representation (romantization by transliteration).

§Features

  • Preserves original whitespace (spaces, tabs, newlines, etc.)
  • Transforms characters from languages like Chinese and Japanese into ASCII
  • Replaces emoji with their name enclosed by colons (e.g., 🍆 becomes :eggplant:)
  • Works in no_std environments

§Examples

use superfold::fold;

// Basic CJK handling
assert_eq!(fold("北亰"), "BeiJing");

// Emoji handling
assert_eq!(fold("🦄"), ":unicorn:");

// Diacritics removal
assert_eq!(fold("café"), "cafe");

// Whitespace and structure preservation
assert_eq!(
    fold("  你好  世界\nNext line with piejlüsse  কথাটা 🦄!"),
    "  NiHao  ShiJie\nNext line with piejlusse  kthata :unicorn:!"
);

Functions§

fold
Converts Unicode text to ASCII representation while preserving structure.