Str::slug() drops combining marks, misspelling Thai, Hindi and decomposed accents

Open
#829 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@phattarachai is already working on this.

Since Dec 4, 2026.

  • #830 by @phattarachai — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

Start at the Str::slug() and Str::title() implementations; the issue identifies character handling as the source and suggests walking extended grapheme clusters. Check the existing string tests for slug and title behavior, then add coverage for combining marks in Thai, Hindi, and decomposed accents. Done when those marks are preserved and the decomposed title is not split into a new word; pull request #830 is already open.

Written by the indexing model from the issue text.

Description

Str::slug() keeps letters and digits by checking each char with is_alphanumeric(). A combining mark (Unicode category M) is not alphanumeric on its own, so it is dropped even when it belongs to the letter before it. Text in Thai, Hindi and other scripts that write vowels or tones as marks comes out misspelled, and an accent stored in decomposed form (NFD, common in text that came through macOS) disappears.

use laravel::str::Str;

"ร้านทอง ออนไลน์".slug();      // "รานทอง-ออนไลน"   expected "ร้านทอง-ออนไลน์"
"น้ำแข็ง".slug();              // "นำแขง"          expected "น้ำแข็ง"
"नमस्ते दुनिया".slug();        // "नमसते-दुनिया"    expected "नमस्ते-दुनिया"
"Cafe\u{301} vu".slug();       // "cafe-vu"         expected "cafe\u{301}-vu"
"Café vu".slug();              // "café-vu"         (the same word, precomposed)

The Thai results are different words: the tone mark ้ (U+0E49), the ็ (U+0E47) and the ์ (U+0E4C) are gone. The same word also gets two different slugs depending on whether é is one code point or e plus U+0301, while the docs say the slug "keeps letters and digits as they are, accents included".

Str::title() has the same cause: after a decomposed accent it starts a new word, so "re\u{301}sume\u{301}".title() gives "Re\u{301}Sume\u{301}".

For reference, PHP Laravel's Str::slug($value, '-', null) gives the same รานทอง because its [^\pL\pN\s] class has no \pM; with the default language: 'en' it returns an empty string for Thai. So this looks inherited rather than intended.

A fix is to walk extended grapheme clusters instead of chars and keep or drop the whole cluster based on its first character. I'll open a PR with that.

Dominant language
Rust
Stars
847
Forks
174
Avg merge
5h 40m
Merged PRs (30d)
167

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from laravel/rust-framework

All issues in laravel/rust-framework

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.