How to fix the character set (charset) issue

A number of our customers are experiencing this issue. The problem occurs because 000webhost’s servers are already specifying the character set within the transfer protocol, that being UTF-8. This causes the browser to overwrite the chosen charset inside the document with that provided by the server.

UTF-8 however does not cover all characters with all accents, therefore we’ve created this tutorial which will help you overwrite server’s configuration.

For plain HTML documents

  1. Go to 000webhost cPanel (choose the website you’re working with) > Tools (from left menu) > File Manager > Upload files now

  2. Go to /public_html folder

  3. Double click on .htaccess file (if you have no such file, go to the top right corner of the screen, and select “New File”. Name it .htaccess)

  4. Add this code to a new line: AddDefaultCharset Off

  5. Save the file.

Now you can specify the character set inside the document by appending

<meta charset="CHARACTER_SET"> tag within <head> [...] </head>

…and your website will display properly :wink:

For PHP scripts

  1. Download a FTP client.

  2. Connect to files.000webhost.com with your website’s credentials (Set Security to: Plain FTP)

  3. Open your PHP script

  4. Add this at the beginning of your file:
     
    <?php header("Content-Type: text/html; charset=%CharSet%", true); ?>
     
    Replace %CharSet% with your desired character set :wink:

  5. Save your file

NOTES:

  1. No, this form does not modify your original documents.
  2. No, this form does not convert characters from another area into UTF-8! This is simply a trick to force 000webhost’s servers to specify the chosen charset to the browser.
  3. To add either <meta charset> tag to your HTML document, or header() function to your PHP script, first download it using a FTP client, and then modify it manually using a text editor (preferable Notepad++). Then upload your document to your server again.

If you have any questions or any bugs to report, please do post them here. :slight_smile:

4 Likes

Thank you for this, it has been moved to the tutorials category for better referencing :grimacing:

1 Like

Glad a fix was found. That was starting to become a problem. :grinning:

1 Like

thank you for your reply
I understand pretty well what you say, consider that my site has been developed with codeigniter, I create a folder named convert in mywebsite / forget it is in the folder public_html?

Then if I move the files on which I want to apply the conversion to the convert folder, will the referencing in my controller code for example ($this->load->view(‘my_page’) ) always work? Or after conversion, do I have to re-file the files in the view folder so that it works?

The conversion only changes the string matched inside the document(s) with the extension you provided.

For example: Your documents have .html extension

If you had this code: ($this->load->view('my_page.html') )
It will become ($this->load->view('my_page.php') )

If your documents already had .php extension, nothing will be changed, except the provided character set :wink:

This gives the option to convert all link extensions from .htm to .php
This is good for internal links, but, it would also convert all links to external sites, the external links would then be ‘dead’.

It would be more useful to have 000webhost’s servers not specifying the character set within the transfer protocol.

i do not understand this

@hassanmaleki
See ISO-8859-1 is not showing letters with accents

A simpler solution that worked for me, is adding the following line to the websites .htaccess file:

AddCharset iso-8859-1 .html .htm

This will override the servers default charset with ISO-8859-1 on all documents with a .html or .htm extension

1 Like

For me,
AddDefaultCharset off
works fine.

I was not aware this could be done using .htaccess

Thank you! :smiley:


I have updated the tutorial. No need for extra files to be downloaded.

Many thanks to @panterhz ! :wink:

bsananda asked me “how do you do this?” concerning my statement “For me, AddDefaultCharset off works fine”. A description of what I did follows.
There was a file .htaccess in the root directory of my site, and it consisted of the four lines between the horizontal rules below (an empty first one taken into account):


HTID:1162044: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW

php_value display_errors 1
# DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:1162044:

I modified the file in question by adding the following line after the last one:
AddDefaultCharset off

buenas tardes de que me habla cuando ud me dice que ya no era conciente de lo que estaba sucediendo ?

I am sorry, could you please rephrase or post in english?

I did not catch that…

how do you do this?
how do you do this

Modified it how?
with what application?
text doesn’t work
because windows doesn’t allow me to save a file
without designation

Go to 000webhost cPanel > Your website > File Manager > /public_html > double click on .htaccess
and add to a new line:

AddDefaultCharset off

Right now
the file manager
only shows error 200
part of the file manager problem
on my free website

What is your website URL? :confused:

dabase.org
dabase.org

Hmm… There may be some issues with File Manager because of network downtime.

I’ll contact the admins about it. Meanwhile, please try again later :wink: