PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > UTF-8 and capitalize issues
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
UTF-8 and capitalize issues

Réponse
 
LinkBack Outils de la discussion
Vieux 09/03/2006, 18h22   #1
Cameron Perry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut UTF-8 and capitalize issues

Hi everyone,

I'm applying the capitalize modifier to a particular text variable,
which works as expected in most cases. What has recently come up is
that non-english characters are throwing a bit of a kink into my
plan. For example, Galápagos is coming out as GaláPagos with the
capitalize modifier.

I looked through the forums and didn't find any solutions that
worked, including using the setlocale() PHP function on my page...
All my Smarty template pages are set to charset=utf-8 in the headers,
and my mysql tables and text fields are utf8_general_ci.

So at this point I'm at a bit of a loss as to what I should do next.

Any ideas?


Thanks!
Cameron
  Réponse avec citation
Vieux 09/03/2006, 18h28   #2
Vicente Werner
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] UTF-8 and capitalize issues

The problem is that regexp expressions DON'T work correctly with UTF-8
strings. Wait until php6 to have it solved


On 3/9/06, Cameron Perry <lists@filled.us> wrote:
>
> Hi everyone,
>
> I'm applying the capitalize modifier to a particular text variable,
> which works as expected in most cases. What has recently come up is
> that non-english characters are throwing a bit of a kink into my
> plan. For example, Galápagos is coming out as GaláPagos with the
> capitalize modifier.
>
> I looked through the forums and didn't find any solutions that
> worked, including using the setlocale() PHP function on my page...
> All my Smarty template pages are set to charset=utf-8 in the headers,
> and my mysql tables and text fields are utf8_general_ci.
>
> So at this point I'm at a bit of a loss as to what I should do next.
>
> Any ideas?
>
>
> Thanks!
> Cameron
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
Vicente Werner y Sánchez
  Réponse avec citation
Vieux 09/03/2006, 19h37   #3
messju mohr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] UTF-8 and capitalize issues

On Thu, Mar 09, 2006 at 09:22:45AM -0800, Cameron Perry wrote:
> Hi everyone,
>
> I'm applying the capitalize modifier to a particular text variable,
> which works as expected in most cases. What has recently come up is
> that non-english characters are throwing a bit of a kink into my
> plan. For example, Galápagos is coming out as GaláPagos with the
> capitalize modifier.
>
> I looked through the forums and didn't find any solutions that
> worked, including using the setlocale() PHP function on my page...
> All my Smarty template pages are set to charset=utf-8 in the headers,
> and my mysql tables and text fields are utf8_general_ci.
>
> So at this point I'm at a bit of a loss as to what I should do next.
>
> Any ideas?


write and use your own utf-8 aware modifier, like this one:

<?php

function smarty_modifier_mb_capitalize($string, $uc_digits = false)
{
return preg_replace_callback('!\b\w+\b!u', 'smarty_modifier_mb_capitalize_ucfirst', $string);
}

function smarty_modifier_mb_capitalize_ucfirst($string)
{
return mb_strtoupper(mb_substr($string[0], 0, 1)) . mb_substr($string[0], 1);
}

?>



> Thanks!
> Cameron
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFEEHXVubKPpFA4n0URAn6RAJsERJ/LZTYiBdauCfW7dEVVcS9bywCdFgiW
Cw6Gn4a5Zms57xDsEpzsitU=
=Eo1S
-----END PGP SIGNATURE-----

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h25.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11210 seconds with 11 queries