Cookies ahead

Our support chat tool "Intercom" would like to collect some more data on you. See the related link for more details.

Docs

Encoding

Reviewedbyfl

Markdown ↓

📝

Configure character encoding properly.

UTF-8 is the default encoding for fortrabbit apps. You can configure a different character encoding if needed. This guide explains how.

PHP

PHP writes the encoding in the Content-type header. The default charset is UTF-8Content-type: text/html; charset=UTF-8. You can change the charset via ini_set. Here is an example:

ini_set('default_charset', 'iso-8859-15');
php

Make sure to write this in all your root PHP files. Alternatively, you can use the header() function to set the charset explicitly:

header('Content-Type: text/html; charset=iso-8859-1');
php

HTTP/Apache

Any static file — .txt or .html — is delivered directly via Apache. By default, Apache assumes the file is utf-8. You can change the charset via an .htaccess directive. Here is an example:

AddDefaultCharset iso-8859-1
apache

MySQL

When you store or fetch data from MySQL, you need to ensure the encoding matches the database when you connect to it. You can also set specific encoding for your columns. To set a different encoding than UTF-8 for your database sessions from PHP, you can use the mysql_set_charset() function. Here is an example:

mysql_set_charset('iso-8859-15', $connection);
php

Written by a human. Review, grammar checks and typo fixes by AI.

AI use & editorial processEdit on GitHub ↗