0

My code:

echo mb_convert_case('Björk Guðmundsdóttir', MB_CASE_UPPER, 'UTF-8');
echo mb_convert_case('Björk Guðmundsdóttir', MB_CASE_LOWER, 'UTF-8');

and the output:

BJRK GUMUNDSDTTIR
bjrk gumundsdttir

Some characters were deleted. Anyone know why?

UPDATE 1:

I noticed that my PHP file was note saved as UTF-8. So, I saved it as UTF-8 and ran the code again. My new results:

BJÖRK GUÃMUNDSDÓTTIR
björk guðmundsdóttir

UPDATE 2:

I guess the problem was just that it was being displayed weird in the browser. Solved by adding header('Content-Type: text/html; charset=utf-8');

snoopy76
  • 305
  • 2
  • 7
  • 15

1 Answers1

1

Firstly make sure your editor is set to UTF-8 without BOM, then you must make sure that the text you passed to the function is actually UTF-8, since that is what you specified as the third argument. Then it should work

EDIT: You might also want to check that your browser is interpreting the characters correctly and make sure the page is setting the content-type, using either a <meta> tag or PHPs header()

user1909426
  • 1,658
  • 8
  • 20
  • Those characters are UTF-8, right? I'm using Zend Studio and think I have it set to UTF-8 properly. Still not working. – snoopy76 Apr 10 '13 at 01:14