Jump to content

utf8_encoding() removes Euro sign


bambinou1980

Recommended Posts

Hi Jacques,

 

What I am not understanding is that my form where the data is passed has <meta charset="UTF-8"> to the top, is this not enough to change the data to UTF-8 upon submission?

 

Regarding the ISO-8859-1-encoded that you are speaking about, it should not happen if I have <meta charset="UTF-8"> at the top of the page no?

 

 

Thank you,

Link to comment
Share on other sites

Character encodings are a bit tricky, because there are many places where things can go wrong.

 

The character encoding of your webpages should be declared in the Content-Type HTTP header. This can either be done by the webserver (which is preferrable) or within PHP:

header('Content-Type: text/html; charset=UTF-8');

In addition to that, you might use a <meta> element. This is primarily meant as a fallback mechanism for offline documents (when the HTTP headers are no longer available). Note that the Content-Type header takes precedence over the <meta> element. Also note that the meta character encoding should be declared as early as possible, because browsers will only scan the first few bytes of the document. A good place is right after the opening <head> tag.

 

If you do this, then, yes, both the input and the output will use the UTF-8 encoding.

 

In case you store the data, you must also make sure that the database connection and the database itself use UTF-8. This is not the default. MySQL typically uses “Latin-1” (ISO-8859-1), so that's another common source for errors.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.