How to fix the character set (charset) issue


#1

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 > File Manager

  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:


ISO-8859-1 is not showing letters with accents
<meta charset="utf-8" /> no funciona de repente (not working all of a sudden)
New panel webpages show multiple � unicode characters
Bad site appearance after site transfer to new area
Вопрос по сайту
После установки выдает http error 500
Adding Arabic language in files
Las letras con acentos gráficos me aparecen como símbolos
Problem with accented letters
Text Format Problems in HTML files
Codecharge built website problem with Greek characters
Don't display special characters after migration �
No more accents in my pages on your new platform?
ÅÄÖ gone after migration from old webhost server
Problem with charset and website builder
Displaying web page problems
Hungarian fonts problem
Las imagenes que contienen la ñ no me las muestra
On my website every é-ö-€- or such signes appear as a question mark
Header 'Last-Modified' for HTML content
Al subir archivos los deja vacios
После установки выдает http error 500
What can I do for contact form send mails from my website?
#2

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


#3

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


#4

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?


#5

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:


#7

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.


#8

i do not understand this


#9

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


#10

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


#11

For me,
AddDefaultCharset off
works fine.


#12

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:


#14

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


#15

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


#16

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

I did not catch that…


#17

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


#18

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

AddDefaultCharset off


#19

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


#20

What is your website URL? :confused:


#21

dabase.org
dabase.org


#22

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: