Re: [Tiki-devel] A Unicode-aware replacement for the natcasesort() function

Volker Wysk <post-hhF2Jplw28UoZk/[email protected]>
Newsgroups gmane.comp.cms.tiki.devel
Message-ID <[email protected]>
Hi.

Does anyone know how to check if the intl PHP extension is available?

Bye
V.W.

Am Freitag, dem 07.07.2023 um 13:31 +0200 schrieb Volker Wysk:
> Hi!
> 
> Here it is:
> 
> ----------------------------------------------------------------------------
> // Do a natural, locale aware sort of an array of strings.
> //
> // "Natural" means that numbers are sorted by their value, not by the digits
> // they contain. For instance, "10" is ordered after "2".
> //
> // The "lang" argument is the language for which to order. Accented
> // characters, like "ä", are ordered with their non-accented counterpart, 
> // like "a". In the non-locale aware natcasesort() function, accented 
> // characters get ordered at the end. That's not right for non-English 
> // languages.
> //
> // For the "lang" argument, "false" can be specified. In this case, the 
> // function investigates the language of the current user and uses that.
> //
> // mb_natcasesort() depends on the "intl" PHP extension.
> 
> function mb_natcasesort(string $lang, array &$array): bool
> {
>     if ($lang == false) {
>         $tikilib  = TikiLib::lib('tiki');
>         $loginlib = TikiLib::lib('login');
> 
>         $user = $loginlib->getUser();
>         $lang = $tikilib->get_language($user);
>     }
> 
>     $coll = collator_create($lang);
>     collator_set_attribute($coll, Collator::NUMERIC_COLLATION, 
>                            Collator::ON);
>     collator_set_attribute($coll, Collator::CASE_FIRST, 
>                            Collator::LOWER_FIRST);
>     collator_set_attribute($coll, Collator::ALTERNATE_HANDLING, 
>                            Collator::SHIFTED);
> 
>     return collator_asort($coll, $array);
> }
> ----------------------------------------------------------------------------
> 
> Any comments are welcome.
> 
> Regards,
> Volker
> _______________________________________________
> TikiWiki-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmSpT20ACgkQ+K4ydFOs
HoUSwQ/+NrY7RE993wXieX6davjfIL+1A3yM0JFlOVBBbZ/45AwLryBFi2tjyf/e
hfdwg0019FLNVlrJpF7+yfXoxC/17GsNkSfoUEiamJE3qQP/iOO+K+ZyUu4dJh7G
MMXdoskPZBLPd2hku9077HKYrVSUn9WAyyZKjhyjBC2Jh/8No/Bp4BMEnTeiKobG
oeUWZ/LJKm9gQALYzITMOu1X0a1plSOthbwvm4HqxVqaYQMbVQnwZf0PqOBkkPDe
NdP5YxwAV1kwLWnHkcTLK38xArqaVOVYcjMHHTgKEGeDPcC1XK9H+XzKq00IgNpn
fdtjdkiFB7doeCBBaSLAx5GRO8nmE6I8drZ1gJmVpJa2bcRJgYbUvIRkimpANozv
mp/VBn0ea+8Jtb6LQ9CXwh60gx++5tS6a9qumbJnUUSqZc+z6ru1725Ft4+RVbdu
iCciAiW0FQseKs0h2JtMyeI6s96C4aUvcmPWxfmDbz6gOY1NuFr6NklE57xN49P/
SvbDF6Rkwkx5zVeh9ulU8N1JNHr3Iin47tmBZ3bqwnzrm3JME3l/2fIc4+tBuSWB
XD5vL/hBGIPPJHF+ssVg6Qjhs+ykPaErQJGs2VLNDyLaPPtLnvtu9J5QviYHoPG9
PupbI22I+xm7qG8LZoLQPKlQzMceVW2Jp8I0cGY+shfwH2k7YRI=
=T4mC
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.