Intended audience: users, XHTML/HTML coders (using editors or scripting), script developers (PHP, JSP, etc.), Web project managers, and anyone who needs to know how to check the character encoding used by the HTTP header.
Jak można sprawdzić informacje kodowania znaków wysłaną w nagłówku HTTP dokumentu?
Ważnym jest aby wyraźnie określić kodowanie znaków (charset) dokumentu
udostępnionego w sieci. W przeciwnym razie odbiorca może niewłaściwie zinterpretować dokument. Przeglądarka na przykład może wyświetlić znaki na
chybił trafił zamiast przedstawić je w formie czytelnej. Jednym sposobem określenia kodowania znaków dokumentu jest umieszczenie tej informacji w
parametrze charset
nagłówka Content-Type
.
In particular, it is important to note that the encoding declared in the HTTP header overrides all in-document encoding declarations in HTML and CSS files.
Istnieje wiele sposobów sprawdzania dokumentu, w tym sprawdzania nagłówków:
The Internationalization Checker tool, developed by the W3C, checks web pages for various internationalisation issues. It also has an information section that summarises key internationalization-related information about a page, such as character encoding and language declarations, etc. That section tells you whether an encoding declaration is used in the HTTP header, and if so, what is the encoding.
The i18n checker tool is particularly useful, since it also shows you other encoding declarations used in the document, and raises a flag if there are differences.
Istnieje wiele usług internetowych, które wyświetlają wszystkie nagłówki HTTP i źródło (HTML/XHTML) dokumentu po powrocie z serwera po tym jak wprowadzi się adres dokumentu, którym jesteś zainteresowany:
Uwaga: W3C nie ma powiązań z takimi usługami.
W nagłówkach HTTP szukaj nagłówka Content-Type
a w szczególności parametru charset
. Np:.
Content-Type: text/html; charset=utf-8
Uwaga: Parametr charset
nie musi być obecny. Jest to na tyle właściwe jak długo dokument sam określa swoje własne
kodowanie.
Modern desktop browsers usually contain a set of web developer tools, and they can be used to view HTTP headers of a web document and its related resources. Here's how to do it in major browsers.
Content-Type
header, and in particular for the charset
parameter.Content-Type
header, and in particular for the charset
parameter. telnet
lub innego narzędzia komendWymaga to trochę ekspertyzy, ale jest łatwiejsze do zautomatyzowania. Inną komendą jest wget
(z opcją -S
lub-s
).
Niektóre serwery kodują dokumenty w różnych kodach znaków dla różnych klientów. Dzieje się tak np. w Rosji. Wymaga to specjalnej uwagi, ponieważ przeglądarka w systemie Windows czy Mac może wskazywać użycie kodów innych niż te określone przez usługi sieciowe albo W3C Markup Validation Service (które w większości przypadków oparte są na systemach UNIX).
Linki Pokrewne, Setting up a server
Linki Pokrewne, Authoring HTML & CSS
Linki Pokrewne, Authoring SVG