Typo3 output UTF-8 in your own extensions

After you had finally master your the utf8 convert of you Typ3 installation may encounter an other problem. Your own extension is not producing utf8 output.
Your first idea will be to add "SET NAMES UTF8;" to you database connection when using the DBAL of Typo3. But this is not your problem 😉 $GLOBALS['TYPO3_DB']->exec_SELECTquery (which is actually using the DBAL) gives your right want you want!

After a while you’ll may find out that you’ve used for some reasons htmlentities. And this is your problem! But don’t panic. You just need to added some more parameters and the world will be fine again. Just add ‚UTF-8‘ as third parameter to give the function a hint that you are using uft8. Tricky … isn’t it 😉

So it will look similar like this:
$str = htmlentities( $dbData, ENT_COMPAT, 'UTF-8' );