Send emails with international accent and special characters

You need to use MIME. Add mail headers: MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 (If you are already using a MIME multipart/alternative to put HTML and text in the same mail, you put the Content-Type: text/plain;charset=utf-8 on the sub-headers of the text part instead.) This is assuming that the encoding you’ll be sending your “international” characters in … Read more

Decoding numeric html entities via PHP

html_entity_decode already does what you’re looking for: $string = ‘’’; echo html_entity_decode($string, ENT_COMPAT, ‘UTF-8′); It will return the character: ’ binary hex: c292 Which is PRIVATE USE TWO (U+0092). As it’s private use, your PHP configuration/version/compile might not return it at all. Also there are some more quirks: But in HTML (other than XHTML, which … Read more

The ultimate emoji encoding scheme

MySQL’s utf8 charset is not actually UTF-8, it’s a subset of UTF-8 only supporting the basic plane (characters up to U+FFFF). Most emoji use code points higher than U+FFFF. MySQL’s utf8mb4 is actual UTF-8 which can encode all those code points. Outside of MySQL there’s no such thing as “utf8mb4”, there’s just UTF-8. So: Does … Read more

UTF-8 not working in HTML forms

In your HTML, add this meta tag: <meta http-equiv=”Content-Type” content=”text/html;charset=UTF-8″> Also add this PHP header at top of the script: header(“Content-Type: text/html;charset=UTF-8”); [EDIT]: One more tip is to save the file as UTF-8 without BOM encoding. You can use Notepad++ or any decent editor to do that.

fwrite() and UTF8

If you know the data is in UTF8 than you want to set up the header. I wrote a solution answering to another tread. The solution is the following: As the UTF-8 byte-order mark is \xef\xbb\xbf we should add it to the document’s header. <?php function writeStringToFile($file, $string){ $f=fopen($file, “wb”); $file=”\xEF\xBB\xBF”.$file; // this is what … Read more