List Info

Thread: UTF-8 and capitalize issues




UTF-8 and capitalize issues
user name
2006-03-11 00:45:59
Thanks for the tip Messju, though it doesn't seem to be
working  
properly for me... the letter immediately following the
accented  
character is capitalized using the functions below...

I also tried a few different methods, but it seems there's 

*something* wrong here. If I try the mb_convert_case()
function to  
convert to all upper-case: mb_convert_case($string 
[0],MB_CASE_UPPER,"UTF-8"); all the characters
except the accented  
ones are converted to upper-case. Galápagos -> GALáPAGOS.
I also  
tried the mb_convert_encoding to UTF-8, but to no avail.

Does it maybe have something to do with the way I'm
entering the  
characters? On my Mac I type option-e then the vowel (eg,
á), but I  
really doubt that's the problem. (Also recall that my db
tables are  
all utf8_general_ci)

Thanks a million!
Cameron

On Mar 9, 2006, at 10:37 AM, messju mohr wrote:
> 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

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

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )