How to determine character set encoding?

For example, Chinese text (GB2312) is inserted into the text box (or text area) of the html page and the form is published. On the server side, are there any means by which this character set will be detected?

How will this detection be carried out if texts belonging to different character sets are inserted into the text box?

+3
source share
3 answers

You need to tell the browser which encoding to use by adding the accept-charset = "UTF-8" (or similar) attribute to the form. Apparently this defaults to the character set of the page , but I wouldn't count on it. The browser will not tell you what encoding is used when submitting the form, so you need to assume that it used the one you told him.

+2
source

The web browser must send the type of content, including the encoding, when it sends the data.

" " ( - ) , . , ( ) (, , ). , , , , , , .

0

if you use php on the server, you can use mb_detect_encoding

0
source

Source: https://habr.com/ru/post/1716697/


All Articles