mmucklo / MjmKrumoBundle

Symfony2 bundle for using Krumo in symfony2 and symfony3
6 stars 3 forks source link

Encoding Issue when using krumo function in classes and twig templates #5

Open asentner opened 9 years ago

asentner commented 9 years ago

Great debug tool! Our company has used the dsm() in Drupal for years so we were excited to find a port of that functionality in the Symfony framework.

When I run the krumo function in a controller or in a twig template, it messes up UTF-8 encoding. Also, in the Krumo output, it is outputting a weird character on the initial dropdown. Please see the attached image. I noticed specifically when using special characters on a page, they show up weird when the k() function is used.

Can you update to support unicode?

If you find this issue is with the Krumo library itself, let me know and I'll post the issue in that repo.

Version Info: oodle/KrumoBundle 1.0.2 oodle/krumo 0.5.0 symfony/symfony 2.5.8 twig/twig 1.16.2

screen shot 2014-12-06 at 7 17 27 pm

mmucklo commented 9 years ago

Yes probably - let me take a look and find out what's going on.

Matt

mmucklo commented 9 years ago

My first test was to try to output some utf-8 encoded characters from a controller using krumo.

Seemed to work fine:

screen shot 2014-12-06 at 11 54 19 pm

Is the encoding on your web page lined up with the encoding of the content being outputted?

For example, something like this in your <head> section:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
asentner commented 9 years ago

Hey,

I do have the meta tag in my header. I am also able to output utf-8 encoded characters from the controller to krumo. All other encoded characters in the template break when I use krumo though. Very weird.

mmucklo commented 9 years ago

Okay I tried the same thing in a twig template and it worked fine.

                {{ krumo("ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ") }}

screen shot 2014-12-10 at 2 29 46 pm

asentner commented 9 years ago

Weird. It's must be something on my project. Just odd encoding works without the Krumo functions. Let me dig in a bit more. I'll update you all and close this out if I can figure it out. Thanks for taking a look!

wizard-of-vos commented 9 years ago

Solved this by saving the class.krumo.php as UTF-8 WITH BOM (in \vendor\oodle\krumo\class.krumo.php).

mmucklo commented 9 years ago

If you make a pull request I'll merge it...

On Feb 12, 2015, at 5:31 AM, Pablo Vos notifications@github.com wrote:

Solved this by saving the class.krumo.php as UTF-8 WITH BOM (in \vendor\oodle\krumo\class.krumo.php).

— Reply to this email directly or view it on GitHub https://github.com/oodle/KrumoBundle/issues/5#issuecomment-74070291.

asentner commented 9 years ago

Nice. Will git even detect the file encoding change? I'll try on my fork to see