voku / portable-ascii

🔡 Portable ASCII library - performance optimized (ascii) string functions for PHP.
MIT License
536 stars 36 forks source link

Turn this package into a polyfill for transliterator_transliterate() #32

Open nicolas-grekas opened 5 years ago

nicolas-grekas commented 5 years ago

Hi there!

In case you missed it, I'm working on abandoning patchwork/utf8 in favor of https://github.com/symfony/symfony/pull/33553 In this PR, I'm using transliterator_transliterate() to implement UTF-8 to ASCII transliterations (see AbstractUnicodeString::ascii()). But when the intl extension is not installed, I just skip the call and fallback to NFKC + maps + iconv.

It would be super cool if we could polyfill this function from intl (a subset of its behavior at least). This package is the closest I know. Would you consider porting it to https://github.com/symfony/polyfill/tree/master/src/Intl?

GrahamCampbell commented 5 years ago

Interesting. This package is actually brand new, extracted from the Stringy and portable-utf8 packages, and was created, at least in part, by my desire to have Laravel 7 start using this package's ascii conversion: https://github.com/voku/Stringy/issues/20, https://github.com/laravel/framework/pull/29947.

voku commented 5 years ago

@nicolas-grekas interesting package and what a loop :) https://github.com/nicolas-grekas/symfony/blob/string-component/src/Symfony/Component/String/Utf8String.php#L99 ... and yes I can / will try to use this library as polyfill.