xakan, French
@xakan@social.zdx.fr avatar

Moi ce que j'aime avec #PHP, c'est que c'est so 2024.

Genre strtoupper(), la fonction censée convertir les caractères en majuscules, ne gère pas du tout les accents.

Ainsi, strtoupper('très') retournera 'TRèS'.

Classe 😅

Girgias,
@Girgias@phpc.social avatar

@xakan Ouais une "chaîne de caractères" en PHP c'est vraiment juste un byte-array. Et tout ce qui commence par str* fonctionne grosso modo que avec les caractères ASCII.

IIRC si tu utilisais setlocale avec la locale FR ça pouvait convertir certain accent.

Mais setlocale c'est vraiment mal foutu donc bon.

xakan,
@xakan@social.zdx.fr avatar

@Girgias j'ai pu passer par mb_strtoupper que je ne pensais pas meilleur, mais si. C'est réglé donc.

Girgias,
@Girgias@phpc.social avatar

@xakan 👍

j3j5,
@j3j5@hachyderm.io avatar

@xakan sorry if you already know this, but you're suppose to use "mb_strtoupper()" for that:

https://www.php.net/manual/fr/function.mb-strtoupper.php

xakan,
@xakan@social.zdx.fr avatar

@j3j5 I also saw about mb_strtoupper, but I thought it had the same behaviour. In fact, it deals with accented characters :)
Thanks for the reminder ;)

j3j5,
@j3j5@hachyderm.io avatar

@xakan yeah, character encoding is weird, all the mb_ functions deal with the "multi byte" encodings like utf-8, as a speaker of a language with accents (spanish), I always use those just in case :)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • JUstTest
  • ethstaker
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • tacticalgear
  • anitta
  • provamag3
  • Leos
  • cisconetworking
  • megavids
  • lostlight
  • All magazines