0

I'm appending to a div some HTML code which might include special characters (UTF-8).

I'm doing this:

ad_status = '<span style="color:orange;"><strong>Para Aprovação</strong></span>';
$('#meus-anuncios').append(ad_status);

I have the meta for utf-8 in my html file already. Any idea that I could use?

bfavaretto
  • 71,580
  • 16
  • 111
  • 150
pedrotorres
  • 1,222
  • 2
  • 13
  • 26
  • What you're doing doesn't work? If not, how does it fail? – John Dvorak Feb 02 '13 at 00:36
  • 1
    Isn't that working? It should be. Maybe you're missing a server-side header. – bfavaretto Feb 02 '13 at 00:37
  • No it appears like this 'Para Aprova��o' – pedrotorres Feb 02 '13 at 00:40
  • 1
    Works here: http://jsfiddle.net/3x6Pn/ – the system Feb 02 '13 at 00:41
  • Perhaps your javascript file is delivered with a wrong charset? – John Dvorak Feb 02 '13 at 00:43
  • i already tried that... changed my IDE configuration... but it didn't work... maybe i am doing it wrong – pedrotorres Feb 02 '13 at 00:44
  • @pedrotorres the IDE configuration likely doesn't matter. What matters is the charset that the server sends. Please investigate the network headers for the javascript file. – John Dvorak Feb 02 '13 at 00:47
  • 3
    @JanDvorak The encoding the file is saved with also matters. If it's saved as latin 1 and served as UTF8, it will break. – bfavaretto Feb 02 '13 at 00:49
  • @bfavaretto That's what I'm starting to think happens here. – John Dvorak Feb 02 '13 at 00:50
  • Make sure you're saving the file as utf8. That's something you should be able to set from your IDE. Then make sure you're serving the file as utf8 too. That's a webserver configuration, which usually can be overridden from your server-side language of choice. This might help: http://www.w3.org/International/questions/qa-changing-encoding, and http://htmlpurifier.org/docs/enduser-utf8.html – bfavaretto Feb 02 '13 at 00:53
  • im checking my request, and its going with "charset=utf-8" but the response has "charset=ISO-8859-1"... am i allowed to change this? – pedrotorres Feb 02 '13 at 00:56
  • Yes, what server side language are you using? – bfavaretto Feb 02 '13 at 00:57
  • i am using PHP. but this string with special character is created in the javascript file. its all client-side. – pedrotorres Feb 02 '13 at 01:00
  • That's weird. You may need to tweak your webserver settings. But before trying into that, try just ``. And again, make sure the js file is saved as utf8. – bfavaretto Feb 02 '13 at 01:13
  • well it seem that filezilla wasn't sending my files as UTF-8. thank you guys – pedrotorres Feb 02 '13 at 02:51
  • Check the HTTP headers. The Apache AddDefaultCharset setting could need tweaking/disabling. –  Feb 02 '13 at 04:18

0 Answers0