")" statement; 2. Use "res.setHeader()" or "res.writeHeader( )" sets the Content-type type."/> ")" statement; 2. Use "res.setHeader()" or "res.writeHeader( )" sets the Content-type type.">
Home > Article > Web Front-end > How to set encoding using nodejs
Method: 1. Use the "res.write("93f0f5c25f18dab9d176bd4f6de5d30e33743b8a6ea7f50d6b14eaf8a155181d9c3bca370b5104690d9ef395f2c5f8d1")" statement; 2. Use "res. setHeader()" or "res.writeHeader()" sets the Content-type type.
The operating environment of this tutorial: windows7 system, nodejs version 12.19.0, DELL G3 computer.
Nodejs method of setting encoding
1. Use res.write() to set the meta tag
res.write("<head><meta chartset='uft-8'/></head>")
2. Use res.setHeader() or res.writeHeader() to set Content-type
res.setHeader("Content-type","text/html;charset=utf8"); res.writeHeader(200,{"Content-type":"text/html;charset=utf8"})
Instructions: Content-Type
Content-Type (content type) generally refers to the Content-Type that exists in a web page. It is used to define the type of network files and the encoding of the web page. It determines in what form and what encoding the browser will read the file. This is often I see that the result of clicking on some PHP web pages is to download a file or an image.
The Content-Type header tells the client the content type of the actual content returned.
Grammar format:
Content-Type: text/html; charset=utf-8 Content-Type: multipart/form-data; boundary=something
[Recommended learning: "nodejs tutorial"]
The above is the detailed content of How to set encoding using nodejs. For more information, please follow other related articles on the PHP Chinese website!