Page 1 of 1

strtoupper

Posted: Sat Jul 24, 2010 9:02 am
by spacebiscuit
Hi,

I'm using the strtoupper function to convert a string to upper case. The string in this case features a foreign language character:

รบ

When I output the string this character remains lower case whilst those aorund it are upper case. If I manually post in the uppercase character it correctly displays an uppercase.

I am wonderiing if this has something to do with the charset in the HTML heading?

Rob.

Re: strtoupper

Posted: Sat Jul 24, 2010 12:35 pm
by cpetercarter
No, it is to do with the locale set by the operating system of your computer.

Have a look at the php manual entry on strtoupper, particularly the user comments, several of which suggest workrounds for cases where you want to convert non-standard characters to upper case.

Re: strtoupper

Posted: Sat Jul 24, 2010 7:35 pm
by Weirdan
It's likely all you need is mb_strtoupper()

Re: strtoupper

Posted: Mon Jul 26, 2010 7:15 am
by spacebiscuit
Thanks for the rpely.

mb_strupper removed the charachter entirely!

Rob.

Re: strtoupper

Posted: Mon Jul 26, 2010 7:19 am
by Apollo
Did you supply the correct encoding to mb_strtoupper?

If you tell mb_strtoupper that your string is utf-8, but it's really windows-1252 ansi for example, it may remove foreign characters because they're simply invalid bytes when interpreting the string as utf-8.

Re: strtoupper

Posted: Mon Jul 26, 2010 7:34 am
by spacebiscuit
Fantatic that did it! I had to set the encloding to Windows-1252.

Many thanks!

Rob.