Categories
Tutorials

Easily Adding UTF-8 Charset in Nginx

What is a UTF-8


UTF-8 is a variable-width character encoding used for electronic communication. Defined by the Unicode Standard, the name is derived from Unicode Transformation Format – 8-bit. UTF-8 is capable of encoding all 1,112,064 valid character code points in Unicode using one to four one-byte code units. Source Wikipedia

Open Nginx Conf File

You can use simple SSH Command for Nginx

sudo nano /etc/nginx/nginx.conf

Locate the HTTP Block

Add the following to your HTTP Block

charset utf-8;

This Should look like this

# /etc/nginx/nginx.conf

http {

charset utf-8;

}

Restart the Server

Adding UTF-8 with Html

For Single HTML Documents Simply add UTF-8 with meta tags

<meta charset="UTF-8">

or This Should be in your <head> tag

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Test after adding UTF-8

You can test the UTF-8 With restarting your server and using the curl command below

curl -I https://yourdomain.com

This will output at the top with the following line

HTTP/1.1 200 OK
Powered-By: PHP/7.4
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8

By Rahul Kharbanda

Hi,
I am Rahul Kharbanda from India. I hope you like all the content I made. Welcome to comment & connect.
I am on Quora , Github , Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *