Skip to main content

DISPLAYING CHINESE CHARACTERS IN HTML

Make a Donation
FatWallet Coupons and DealsGetting extended character sets to display correctly in HTML is a bit of a minefield. There are lots of things which can trip you up on this journey.

To make things even more complicated, there are numerous different sub-sets of Chinese characters which you'll need to be able to display. for example:

simplified Chinese: 汉语;
traditional Chinese: 漢語;
Pinyin: Hànyǔ;
simplified Chinese: 华语;
traditional Chinese: 華語;
Chinese: 中文;
This article will help you get over some of the most simple obstacles

CHARSET

Life will be a lot easier if we make sure we're using the correct Charset: UTF-8. You'll need to make sure that you have the right content-type header in your HTML to start with:



This will need to go in the section of your web page.

SERVER HEADERS

Make sure that your webserver is sending the correct HTTP content-type header as well. The Firefox developer toolbar can check your server response headers: it is under the "Information" menu.

The server should be sending a response header like this:

Content-Type: text/html; charset=UTF-8

If the "charset=UTF-8" bit is missing from the Content-Type response header, or if it says something other than "UTF-8", then this will cause you problems. Ideally, you need to fix this in your server config, but you could also use a PHP header() directive at the top of a scripted document to make sure that your server sends the correct header.

FILE / FTP ENCODING

This one has caught everybody out at one time or another.

You must make sure that your save your document in UTF-8 format and upload the document to your webserver so that the format is preserved. Some text editors won't save in UTF-8 format. Windows users might want to look at TextPad, which supports UTF-8. As  Mac user, I prefer BBEdit.

When FTPing your file up to the server, make sure that the file format is preserved. In some FTP clients, this might mean that you need to FTP the file up to the server as binary file.

THIS IS JUST THE BEGINNING

There are plenty more things which can trip you up on the way to UTF-8 goodness, but these are the basics. If you have a problem trying to display extended character sets, it can usually be traced to a problem somewhere in your document encoding, be it the source files, server headers, or even the database. Good luck. We hope that this article has helped!

Comments

Popular posts from this blog

CKA Simulator Kubernetes 1.22

  https://killer.sh Pre Setup Once you've gained access to your terminal it might be wise to spend ~1 minute to setup your environment. You could set these: alias k = kubectl                         # will already be pre-configured export do = "--dry-run=client -o yaml"     # k get pod x $do export now = "--force --grace-period 0"   # k delete pod x $now Vim To make vim use 2 spaces for a tab edit ~/.vimrc to contain: set tabstop=2 set expandtab set shiftwidth=2 More setup suggestions are in the tips section .     Question 1 | Contexts Task weight: 1%   You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts . Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh , the command should use kubectl . Finally write a second command doing the same thing into ...

OWASP Top 10 Threats and Mitigations Exam - Single Select

Last updated 4 Aug 11 Course Title: OWASP Top 10 Threats and Mitigation Exam Questions - Single Select 1) Which of the following consequences is most likely to occur due to an injection attack? Spoofing Cross-site request forgery Denial of service   Correct Insecure direct object references 2) Your application is created using a language that does not support a clear distinction between code and data. Which vulnerability is most likely to occur in your application? Injection   Correct Insecure direct object references Failure to restrict URL access Insufficient transport layer protection 3) Which of the following scenarios is most likely to cause an injection attack? Unvalidated input is embedded in an instruction stream.   Correct Unvalidated input can be distinguished from valid instructions. A Web application does not validate a client’s access to a resource. A Web action performs an operation on behalf of the user without checkin...