php - embedded script displaying gibberish depending on encodying type (utf-8) -


I have a widget that people can put on their site.

The widget is generated through the PHP script which is using the populated string: document.write ('$ widget_output').

The hosting site calls on the widget using JavaScript tags:

  & lt; Script type = "text / javascript" src = "http://www.link.com/page.php?param=1" & gt; & Lt; / Script & gt;  

The problem is that my widget is UTF-8 and sometimes it is different from hosting the website, which can cause ambiguous text to be displayed to the widget.

Is anyone the way to decide that it works under any circumstances?

Thank you!

Add a content-encoding http header (typed quickly on my iPhone)

< P> Let me tell it a little further (writing on my laptop ;-) Browser requests various resources from the server Every browser uses Unicode to represent data to display internally. Each resource (HTML page, JavaScript file, CSS file etc.) that comes from the web server can optionally attach the encoding information to the HTTP header. If there is a content-encoding header in it, then the browser converts the resource for the internal Unicode representation using encoding from resource headers. If there is no content-encoding header, then the browser assumes that file encoding is similar to the page that requests the resource.

Closing: If you have a script that is used on a web server and used on various encoding pages, make sure that you add content-encoding http headers to that script.


Comments