Search code examples
iosutf-8ios-simulator

UTF-8 does not work in Safari (inside iphone app)


So I have almost no iphone programming experience, yet I have found some basic rss reader code and playing around with it.

The thing is, when I visit the link in my Chrome browser, it works fine in terms of character encoding, but when I visit it through the built-in browser in the iphone app code I have (in iphone simulator), the characters are not displayed properly.

Why it could be?

Edit:

So what I was trying to access over the web browser was a simple UTF-8 text file (I was too lazy to put into an HTML), and I could not see the non-English characters.


Solution

  • You must tell the client that the file is in UTF-8 format. If you are running apache, you can add this to your .htaccess file:

    AddDefaultCharset UTF-8
    

    Or you can put the text into a HTML file and add a meta tag for the charset encoding:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">