From 0f8f6f360cbbbf19bd60f14974b710faad611fc4 Mon Sep 17 00:00:00 2001 From: MDN Date: Tue, 1 Jun 2021 01:52:39 +0000 Subject: [CRON] sync translated content --- files/ja/_redirects.txt | 1 + files/ja/_wikihistory.json | 14 ++--- .../index.html | 58 ++++++++++++++++++++ .../index.html | 57 -------------------- files/ru/_redirects.txt | 1 + files/ru/_wikihistory.json | 14 ++--- .../index.html | 58 ++++++++++++++++++++ .../index.html | 57 -------------------- files/zh-cn/_redirects.txt | 1 + files/zh-cn/_wikihistory.json | 16 +++--- .../index.html | 62 ++++++++++++++++++++++ .../index.html | 61 --------------------- 12 files changed, 203 insertions(+), 197 deletions(-) create mode 100644 files/ja/orphaned/web/guide/localizations_and_character_encodings/index.html delete mode 100644 files/ja/web/guide/localizations_and_character_encodings/index.html create mode 100644 files/ru/orphaned/web/guide/localizations_and_character_encodings/index.html delete mode 100644 files/ru/web/guide/localizations_and_character_encodings/index.html create mode 100644 files/zh-cn/orphaned/web/guide/localizations_and_character_encodings/index.html delete mode 100644 files/zh-cn/web/guide/localizations_and_character_encodings/index.html diff --git a/files/ja/_redirects.txt b/files/ja/_redirects.txt index 154923052d..b407f2a6f4 100644 --- a/files/ja/_redirects.txt +++ b/files/ja/_redirects.txt @@ -4613,6 +4613,7 @@ /ja/docs/Web/Guide/HTML/HTML5/Introduction_to_HTML5 /ja/docs/orphaned/Web/Guide/HTML/HTML5/Introduction_to_HTML5 /ja/docs/Web/Guide/HTML/Introduction /ja/docs/Learn/HTML/Introduction_to_HTML /ja/docs/Web/Guide/HTML/Obsolete_things_to_avoid /ja/docs/conflicting/Learn/HTML/Introduction_to_HTML +/ja/docs/Web/Guide/Localizations_and_character_encodings /ja/docs/orphaned/Web/Guide/Localizations_and_character_encodings /ja/docs/Web/Guide/Performance/Using_web_workers /ja/docs/Web/API/Web_Workers_API/Using_web_workers /ja/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API /ja/docs/Web/API/Page_Visibility_API /ja/docs/Web/Guide/Using_FormData_Objects /ja/docs/conflicting/Web/API/FormData/Using_FormData_Objects diff --git a/files/ja/_wikihistory.json b/files/ja/_wikihistory.json index bd93f7770c..be730f20a5 100644 --- a/files/ja/_wikihistory.json +++ b/files/ja/_wikihistory.json @@ -33960,13 +33960,6 @@ "silverskyvicto" ] }, - "Web/Guide/Localizations_and_character_encodings": { - "modified": "2020-09-18T02:40:01.125Z", - "contributors": [ - "morinokami", - "silverskyvicto" - ] - }, "Web/Guide/Mobile": { "modified": "2020-03-07T14:24:28.388Z", "contributors": [ @@ -52718,6 +52711,13 @@ "Potappo" ] }, + "orphaned/Web/Guide/Localizations_and_character_encodings": { + "modified": "2020-09-18T02:40:01.125Z", + "contributors": [ + "morinokami", + "silverskyvicto" + ] + }, "orphaned/Web/HTML/Element/command": { "modified": "2020-10-15T21:25:54.776Z", "contributors": [ diff --git a/files/ja/orphaned/web/guide/localizations_and_character_encodings/index.html b/files/ja/orphaned/web/guide/localizations_and_character_encodings/index.html new file mode 100644 index 0000000000..d0b80151b3 --- /dev/null +++ b/files/ja/orphaned/web/guide/localizations_and_character_encodings/index.html @@ -0,0 +1,58 @@ +--- +title: ローカライゼーションと文字エンコーディング +slug: orphaned/Web/Guide/Localizations_and_character_encodings +translation_of: Web/Guide/Localizations_and_character_encodings +original_slug: Web/Guide/Localizations_and_character_encodings +--- +

ブラウザは内部的にテキストを Unicode として処理します。ただし、ネットワークを介してブラウザにテキストを転送するには、文字をバイトで表現する方法 (文字エンコーディング) が使用されます。HTML 仕様では、UTF-8 エンコーディング (これはすべての Unicode を表すことができます) の使用を推奨しています。使用されるエンコーディングにかかわらず、Web コンテンツがどのエンコーディングを使用するかを宣言する必要があります。

+ +

ページの文字エンコーディングを指定するためには、{{HTMLElement("meta")}} 要素の {{htmlattrxref("charset", "meta")}} 属性を使用します。これは {{HTMLElement("head")}} ブロックの中で使用する必要があります

+ +

例えばページが (推奨されている通りに) UTF-8 文字エンコーディングを使用していることを指定するには、{{HTMLElement("head")}} ブロックの中に次の行を記述します:

+ +
<meta charset="utf-8">
+
+ +

詳細とブラウザの内部

+ +

HTML 仕様が要求するように Web コンテンツでエンコーディングが宣言されている場合、Firefox はそのエンコーディングを用いてバイトを内部表現に変換します。残念ながら、UTF-8 を使うことや、UTF-8 の使用を宣言することは、Web コンテンツを提供する上で必ずしも一般的な方法ではありませんでした。1990 年代には、エンコーディングを宣言せずに、すべての Unicode を表現できない地域固有のエンコーディングを使うことが広まっていました。

+ +

Firefox は、エンコーディングを宣言していないレガシーなコンテンツに対して使用するフォールバックエンコーディングを必要とします。ほとんどのロケールでは、フォールバックエンコーディングは (しばしば ISO-8859-1 と呼ばれる) windows-1252 となります。これは 1990 年代にほとんどの Windows アプリケーションで使用されていたエンコーディングであり、またほとんどの Unix アプリケーションで使用されていたエンコーディングのスーパーセットでもあり、アメリカや西ヨーロッパで展開されていました。しかし、1990 年代にはすでに Web パブリッシングが一般的になっていたものの、windows-1252 エンコーディングがその地域の言語に適していなかったようなロケールがあります。これらのロケールにおいて、エンコーディングを宣言していないレガシーなコンテンツは、windows-1252 以外のレガシーなエンコーディングを通常使用しています。レガシーなコンテンツに対応するために、Firefox の一部のローカライゼーションにおいては、windows-1252 ではないフォールバックエンコーディングが必要となります。

+ +

残念ながらこのことは、Web と接する際の Firefox の機能がロケールごとに異なること、そして、フォールバックエンコーディングが異なるロケールをまたいでレガシーなコンテンツを読むのは困難であることを意味します。UTF-8 の採用後に Web パブリッシングが盛んになったロケールでこの問題が発生しないように、1990 年代の慣習から windows-1252 以外のレガシーなエンコーディングをもたないロケールは、フォールバックエンコーディングを windows-1252 とし、フォールバックエンコーディングが windows-1252 である古いロケールをまたぐコンテンツの読解に支障をきたさないようにする必要があります。新しく作成されたロケールネイティブな UTF-8 コンテンツはエンコーディングを宣言することが期待されますが、その場合フォールバックエンコーディングがコンテンツの処理に関与することはありません。

+ +

さらに、1990 年代に地域固有のエンコーディングが一つに定まっておらず、複数のレガシーなエンコーディングをヒューリスティックに検出する機能が Web ブラウザに導入されたロケールが少数存在します。その後 Web 製作者がヒューリスティック検出機能の存在を前提とするようになったことから、Firefox は現在もこれらのロケールにおいてヒューリスティック検出機能を備えています。

+ +

Finding canonical encoding names

+ +

The text below refers to canonical names of encodings. The canonical names are the values to the right of the equals sign in unixcharset.properties.

+ +

Specifying the fallback encoding

+ +

As of Firefox 28, this section is obsolete, since the preference intl.charset.default no longer exists. The mapping from locales onto fallback encodings is now built into Gecko itself.

+ +

The fallback encoding is specified by the preference intl.charset.default in intl.properties. It should be set to the canonical name of the legacy encoding that users of the localizations are most likely to encounter when browsing non-conforming legacy Web content that doesn't declare its encoding. Note that the fallback encoding as defined by the previous sentence does not necessarily need to be able to represent the characters needed for the language of the localization!

+ +

The fallback encoding should be left to windows-1252 for Western European locales, North, Central and South American locales, African locales, Central Asian locales and Oceanian locales. It typically needs to be set to something other than windows-1252 for Central and Eastern European locales, Middle Eastern locales and East Asian locales.

+ +

In order to avoid the problem of Web authors creating new UTF-8 content without declaring that the content uses UTF-8 and in order to maximize the ability of users to read content cross-locale, do not set the fallback encoding to UTF-8 for any newly-introduced localization. Note that Firefox no longer sends the Accept-Charset HTTP header, so there is no need to consider what gets advertised in Accept-Charset when setting the fallback encoding.

+ +

For locales where the fallback encoding is currently ISO-8859-1, it should be changed to windows-1252. ISO-8859-1 is decoded in the exact same way as windows-1252, but Firefox is moving to treating windows-1252 as the preferred label for this encoding in accordance with the Encoding Standard.

+ +

For locales where Internet Explorer has more market share than Firefox, the fallback encoding should typically be set to the same value as in Internet Explorer. You can see the fallback encoding a particular browser has by loading a test page. (Be sure to use a browser installation that has its settings left to the defaults when investigating!)

+ +

For locales where Firefox has more market share than Internet Explorer, it's probably best not to change the fallback encoding even if it doesn't follow the guidance given above. (For example, the fallback encoding for the Polish, Hungarian and Czech locales should probably continue to be ISO-8859-2 even though IE has a different fallback encoding.)

+ +

When in doubt, use windows-1252 as the fallback encoding.

+ +

ヒューリスティック検出モードの指定

+ +

ヒューリスティック検出モードは intl.properties にある intl.charset.detector という設定により指定します。この設定値は、ロシア語、ウクライナ語、そして日本語以外のすべてのロケールでは必ず空でなければなりません。どのような場合においても "universal" 検出器を指定してはいけません。その名前とは裏腹に、まったく普遍的 (universal) ではないためです!

+ +

少数言語に関する例外

+ +

If the localization is for minority language and the users are typically literate in the majority language of the region and read Web content written in the majority language very often, it is appropriate to specify the fallback encoding and the heuristic detection mode to be the same as for the localization for the majority language of the region. For example, for a localization for minority language in Russia, it is appropriate to copy the settings from the Russian localization.

+ +

いくつかのエンコーディングを文字エンコーディングメニューから選びやすくする

+ +

The preference intl.charsetmenu.browser.static in intl.properties makes some character encodings more easily available in the Character Encoding menu in the browser. The value should be a comma-separated list of canonical encoding names. The list should include at least the fallback encoding, windows-1252 and UTF-8. For locales where there are multiple common legacy encodings, all those encodings should be included. For example, the fallback encoding for Japanese is Shift_JIS, but there are other legacy encodings: ISO-2022-JP and EUC-JP. Therefore, it makes sense for the list to be Shift_JIS, EUC-JP, ISO-2022-JP, windows-1252, UTF-8.

diff --git a/files/ja/web/guide/localizations_and_character_encodings/index.html b/files/ja/web/guide/localizations_and_character_encodings/index.html deleted file mode 100644 index 2ac71992d7..0000000000 --- a/files/ja/web/guide/localizations_and_character_encodings/index.html +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: ローカライゼーションと文字エンコーディング -slug: Web/Guide/Localizations_and_character_encodings -translation_of: Web/Guide/Localizations_and_character_encodings ---- -

ブラウザは内部的にテキストを Unicode として処理します。ただし、ネットワークを介してブラウザにテキストを転送するには、文字をバイトで表現する方法 (文字エンコーディング) が使用されます。HTML 仕様では、UTF-8 エンコーディング (これはすべての Unicode を表すことができます) の使用を推奨しています。使用されるエンコーディングにかかわらず、Web コンテンツがどのエンコーディングを使用するかを宣言する必要があります。

- -

ページの文字エンコーディングを指定するためには、{{HTMLElement("meta")}} 要素の {{htmlattrxref("charset", "meta")}} 属性を使用します。これは {{HTMLElement("head")}} ブロックの中で使用する必要があります

- -

例えばページが (推奨されている通りに) UTF-8 文字エンコーディングを使用していることを指定するには、{{HTMLElement("head")}} ブロックの中に次の行を記述します:

- -
<meta charset="utf-8">
-
- -

詳細とブラウザの内部

- -

HTML 仕様が要求するように Web コンテンツでエンコーディングが宣言されている場合、Firefox はそのエンコーディングを用いてバイトを内部表現に変換します。残念ながら、UTF-8 を使うことや、UTF-8 の使用を宣言することは、Web コンテンツを提供する上で必ずしも一般的な方法ではありませんでした。1990 年代には、エンコーディングを宣言せずに、すべての Unicode を表現できない地域固有のエンコーディングを使うことが広まっていました。

- -

Firefox は、エンコーディングを宣言していないレガシーなコンテンツに対して使用するフォールバックエンコーディングを必要とします。ほとんどのロケールでは、フォールバックエンコーディングは (しばしば ISO-8859-1 と呼ばれる) windows-1252 となります。これは 1990 年代にほとんどの Windows アプリケーションで使用されていたエンコーディングであり、またほとんどの Unix アプリケーションで使用されていたエンコーディングのスーパーセットでもあり、アメリカや西ヨーロッパで展開されていました。しかし、1990 年代にはすでに Web パブリッシングが一般的になっていたものの、windows-1252 エンコーディングがその地域の言語に適していなかったようなロケールがあります。これらのロケールにおいて、エンコーディングを宣言していないレガシーなコンテンツは、windows-1252 以外のレガシーなエンコーディングを通常使用しています。レガシーなコンテンツに対応するために、Firefox の一部のローカライゼーションにおいては、windows-1252 ではないフォールバックエンコーディングが必要となります。

- -

残念ながらこのことは、Web と接する際の Firefox の機能がロケールごとに異なること、そして、フォールバックエンコーディングが異なるロケールをまたいでレガシーなコンテンツを読むのは困難であることを意味します。UTF-8 の採用後に Web パブリッシングが盛んになったロケールでこの問題が発生しないように、1990 年代の慣習から windows-1252 以外のレガシーなエンコーディングをもたないロケールは、フォールバックエンコーディングを windows-1252 とし、フォールバックエンコーディングが windows-1252 である古いロケールをまたぐコンテンツの読解に支障をきたさないようにする必要があります。新しく作成されたロケールネイティブな UTF-8 コンテンツはエンコーディングを宣言することが期待されますが、その場合フォールバックエンコーディングがコンテンツの処理に関与することはありません。

- -

さらに、1990 年代に地域固有のエンコーディングが一つに定まっておらず、複数のレガシーなエンコーディングをヒューリスティックに検出する機能が Web ブラウザに導入されたロケールが少数存在します。その後 Web 製作者がヒューリスティック検出機能の存在を前提とするようになったことから、Firefox は現在もこれらのロケールにおいてヒューリスティック検出機能を備えています。

- -

Finding canonical encoding names

- -

The text below refers to canonical names of encodings. The canonical names are the values to the right of the equals sign in unixcharset.properties.

- -

Specifying the fallback encoding

- -

As of Firefox 28, this section is obsolete, since the preference intl.charset.default no longer exists. The mapping from locales onto fallback encodings is now built into Gecko itself.

- -

The fallback encoding is specified by the preference intl.charset.default in intl.properties. It should be set to the canonical name of the legacy encoding that users of the localizations are most likely to encounter when browsing non-conforming legacy Web content that doesn't declare its encoding. Note that the fallback encoding as defined by the previous sentence does not necessarily need to be able to represent the characters needed for the language of the localization!

- -

The fallback encoding should be left to windows-1252 for Western European locales, North, Central and South American locales, African locales, Central Asian locales and Oceanian locales. It typically needs to be set to something other than windows-1252 for Central and Eastern European locales, Middle Eastern locales and East Asian locales.

- -

In order to avoid the problem of Web authors creating new UTF-8 content without declaring that the content uses UTF-8 and in order to maximize the ability of users to read content cross-locale, do not set the fallback encoding to UTF-8 for any newly-introduced localization. Note that Firefox no longer sends the Accept-Charset HTTP header, so there is no need to consider what gets advertised in Accept-Charset when setting the fallback encoding.

- -

For locales where the fallback encoding is currently ISO-8859-1, it should be changed to windows-1252. ISO-8859-1 is decoded in the exact same way as windows-1252, but Firefox is moving to treating windows-1252 as the preferred label for this encoding in accordance with the Encoding Standard.

- -

For locales where Internet Explorer has more market share than Firefox, the fallback encoding should typically be set to the same value as in Internet Explorer. You can see the fallback encoding a particular browser has by loading a test page. (Be sure to use a browser installation that has its settings left to the defaults when investigating!)

- -

For locales where Firefox has more market share than Internet Explorer, it's probably best not to change the fallback encoding even if it doesn't follow the guidance given above. (For example, the fallback encoding for the Polish, Hungarian and Czech locales should probably continue to be ISO-8859-2 even though IE has a different fallback encoding.)

- -

When in doubt, use windows-1252 as the fallback encoding.

- -

ヒューリスティック検出モードの指定

- -

ヒューリスティック検出モードは intl.properties にある intl.charset.detector という設定により指定します。この設定値は、ロシア語、ウクライナ語、そして日本語以外のすべてのロケールでは必ず空でなければなりません。どのような場合においても "universal" 検出器を指定してはいけません。その名前とは裏腹に、まったく普遍的 (universal) ではないためです!

- -

少数言語に関する例外

- -

If the localization is for minority language and the users are typically literate in the majority language of the region and read Web content written in the majority language very often, it is appropriate to specify the fallback encoding and the heuristic detection mode to be the same as for the localization for the majority language of the region. For example, for a localization for minority language in Russia, it is appropriate to copy the settings from the Russian localization.

- -

いくつかのエンコーディングを文字エンコーディングメニューから選びやすくする

- -

The preference intl.charsetmenu.browser.static in intl.properties makes some character encodings more easily available in the Character Encoding menu in the browser. The value should be a comma-separated list of canonical encoding names. The list should include at least the fallback encoding, windows-1252 and UTF-8. For locales where there are multiple common legacy encodings, all those encodings should be included. For example, the fallback encoding for Japanese is Shift_JIS, but there are other legacy encodings: ISO-2022-JP and EUC-JP. Therefore, it makes sense for the list to be Shift_JIS, EUC-JP, ISO-2022-JP, windows-1252, UTF-8.

diff --git a/files/ru/_redirects.txt b/files/ru/_redirects.txt index 5b8b92e802..ac286b6904 100644 --- a/files/ru/_redirects.txt +++ b/files/ru/_redirects.txt @@ -614,6 +614,7 @@ /ru/docs/Web/Guide/HTML/Sections_and_Outlines_of_an_HTML5_document /ru/docs/Web/Guide/HTML/Using_HTML_sections_and_outlines /ru/docs/Web/Guide/HTML/Tips_for_authoring_fast-loading_HTML_pages /ru/docs/Learn/HTML/Howto/Author_fast-loading_HTML_pages /ru/docs/Web/Guide/HTML/Using_data_attributes /ru/docs/Learn/HTML/Howto/Use_data_attributes +/ru/docs/Web/Guide/Localizations_and_character_encodings /ru/docs/orphaned/Web/Guide/Localizations_and_character_encodings /ru/docs/Web/Guide/Графика /ru/docs/Web/Guide/Graphics /ru/docs/Web/Guide/Производительность /ru/docs/Web/Guide/Performance /ru/docs/Web/HTML/CORS_settings_attributes /ru/docs/Web/HTML/Attributes/crossorigin diff --git a/files/ru/_wikihistory.json b/files/ru/_wikihistory.json index 46f8df7e43..8dc219163b 100644 --- a/files/ru/_wikihistory.json +++ b/files/ru/_wikihistory.json @@ -15392,13 +15392,6 @@ "lerniri" ] }, - "Web/Guide/Localizations_and_character_encodings": { - "modified": "2020-12-14T08:44:06.511Z", - "contributors": [ - "azahw935", - "bogpok" - ] - }, "Web/Guide/Parsing_and_serializing_XML": { "modified": "2020-10-11T12:29:17.772Z", "contributors": [ @@ -25692,6 +25685,13 @@ "Grakov" ] }, + "orphaned/Web/Guide/Localizations_and_character_encodings": { + "modified": "2020-12-14T08:44:06.511Z", + "contributors": [ + "azahw935", + "bogpok" + ] + }, "orphaned/Web/HTML/Element/element": { "modified": "2019-03-23T22:16:19.667Z", "contributors": [ diff --git a/files/ru/orphaned/web/guide/localizations_and_character_encodings/index.html b/files/ru/orphaned/web/guide/localizations_and_character_encodings/index.html new file mode 100644 index 0000000000..e40c707ea0 --- /dev/null +++ b/files/ru/orphaned/web/guide/localizations_and_character_encodings/index.html @@ -0,0 +1,58 @@ +--- +title: Локализация и кодировка символов +slug: orphaned/Web/Guide/Localizations_and_character_encodings +translation_of: Web/Guide/Localizations_and_character_encodings +original_slug: Web/Guide/Localizations_and_character_encodings +--- +

По умолчанию браузер обрабатывает текст в кодировке Юникод (Unicode). При этом, при передаче информации через сеть (network) к браузеру символы кодируются байтами (см. кодирование символов). Стандартом HTML рекомендуется использовать кодировку UTF-8 (which can represent all of Unicode) and regardless of the encoding used requires Web content to declare what encoding was used.

+ +

The {{HTMLElement("meta")}} element's {{htmlattrxref("charset", "meta")}} attribute is used to specify the page's character encoding. It must be used within a {{HTMLElement("head")}} block.

+ +

To specify that a page is using, for example, the UTF-8 character encoding (as per the recommendation), simply place the following line in the {{HTMLElement("head")}} block:

+ +
<meta charset="utf-8">
+
+ +

Details and browser internals

+ +

When the encoding is declared by Web content like the HTML specification requires, Firefox will use that encoding for turning the bytes into the internal representation. Unfortunately, using UTF-8 and declaring that UTF-8 was used was not always the prevalent way of offering Web content. In the 1990s, it was common to leave the encoding undeclared and to use a region-specific encoding that wasn't able to represent all of Unicode.

+ +

Firefox needs a fallback encoding that it uses for non-conforming legacy content that doesn't declare its encoding. For most locales, the fallback encoding is windows-1252 (often called ISO-8859-1), which was the encoding emitted by most Windows applications in the 1990s and a superset of the encoding emitted by most UNIX applications in the 1990s as a deployed in the America has and in Western Europe. However, there are locales where Web publishing was common already in the 1990s but the windows-1252 encoding was not suitable for the local language. In these locales, legacy content that doesn't declare its encoding is typically encoded using a legacy encoding other than windows-1252. In order to work with legacy content, some Firefox localizations need a non-windows-1252 fallback encoding.

+ +

Unfortunately, this means that the Web-exposed functionality of Firefox differs by locale and it is hard to read legacy content across locales with different fallback encodings. To avoid introducing this problem in locales where Web publishing took off after the adoption of UTF-8, locales that don't have a non-windows-1252 legacy encoding arising from the practices of the 1990s, should leave the fallback encoding at windows-1252 to facilitate reading content cross-locale from the old locales whose fallback encoding is windows-1252. New-authored locale-native UTF-8 content is expected to declare its encoding, in which case the fallback encoding does not participate in the processing of content.

+ +

Additionally, there is a small number of locales where in the 1990s there wasn't an obvious single region-specific encoding and heuristic detection among multiple legacy encodings was introduced to Web browsers. This has then had the effect that Web authors have depended on heuristic detection being present, so Firefox still has heuristic detection in these locales.

+ +

Finding canonical encoding names

+ +

The text below refers to canonical names of encodings. The canonical names are the values to the right of the equals sign in unixcharset.properties.

+ +

Specifying the fallback encoding

+ +

As of Firefox 28, this section is obsolete, since the preference intl.charset.default no longer exists. The mapping from locales onto fallback encodings is now built into Gecko itself.

+ +

The fallback encoding is specified by the preference intl.charset.default in intl.properties. It should be set to the canonical name of the legacy encoding that users of the localizations are most likely to encounter when browsing non-conforming legacy Web content that doesn't declare its encoding. Note that the fallback encoding as defined by the previous sentence does not necessarily need to be able to represent the characters needed for the language of the localization!

+ +

The fallback encoding should be left to windows-1252 for Western European locales, North, Central and South American locales, African locales, Central Asian locales and Oceanian locales. It typically needs to be set to something other than windows-1252 for Central and Eastern European locales, Middle Eastern locales and East Asian locales.

+ +

In order to avoid the problem of Web authors creating new UTF-8 content without declaring that the content uses UTF-8 and in order to maximize the ability of users to read content cross-locale, do not set the fallback encoding to UTF-8 for any newly-introduced localization. Note that Firefox no longer sends the Accept-Charset HTTP header, so there is no need to consider what gets advertised in Accept-Charset when setting the fallback encoding.

+ +

For locales where the fallback encoding is currently ISO-8859-1, it should be changed to windows-1252. ISO-8859-1 is decoded in the exact same way as windows-1252, but Firefox is moving to treating windows-1252 as the preferred label for this encoding in accordance with the Encoding Standard.

+ +

For locales where Internet Explorer has more market share than Firefox, the fallback encoding should typically be set to the same value as in Internet Explorer. You can see the fallback encoding a particular browser has by loading a test page. (Be sure to use a browser installation that has its settings left to the defaults when investigating!)

+ +

For locales where Firefox has more market share than Internet Explorer, it's probably best not to change the fallback encoding even if it doesn't follow the guidance given above. (For example, the fallback encoding for the Polish, Hungarian and Czech locales should probably continue to be ISO-8859-2 even though IE has a different fallback encoding.)

+ +

When in doubt, use windows-1252 as the fallback encoding.

+ +

Specifying the heuristic detection mode

+ +

The heuristic detection mode is specified by the preference intl.charset.detector in intl.properties. The setting must be left blank for all locales other than Russian, Ukrainian and Japanese. Do not under any circumstances specify the "universal" detector. It is not actually universal despite its name!

+ +

Exception for minority languages

+ +

If the localization is for minority language and the users are typically literate in the majority language of the region and read Web content written in the majority language very often, it is appropriate to specify the fallback encoding and the heuristic detection mode to be the same as for the localization for the majority language of the region. For example, for a localization for minority language in Russia, it is appropriate to copy the settings from the Russian localization.

+ +

Setting some encodings to be more easily selectable from the character encoding menu

+ +

The preference intl.charsetmenu.browser.static in intl.properties makes some character encodings more easily available in the Character Encoding menu in the browser. The value should be a comma-separated list of canonical encoding names. The list should include at least the fallback encoding, windows-1252 and UTF-8. For locales where there are multiple common legacy encodings, all those encodings should be included. For example, the fallback encoding for Japanese is Shift_JIS, but there are other legacy encodings: ISO-2022-JP and EUC-JP. Therefore, it makes sense for the list to be Shift_JIS, EUC-JP, ISO-2022-JP, windows-1252, UTF-8.

diff --git a/files/ru/web/guide/localizations_and_character_encodings/index.html b/files/ru/web/guide/localizations_and_character_encodings/index.html deleted file mode 100644 index 1da05508fd..0000000000 --- a/files/ru/web/guide/localizations_and_character_encodings/index.html +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: Локализация и кодировка символов -slug: Web/Guide/Localizations_and_character_encodings -translation_of: Web/Guide/Localizations_and_character_encodings ---- -

По умолчанию браузер обрабатывает текст в кодировке Юникод (Unicode). При этом, при передаче информации через сеть (network) к браузеру символы кодируются байтами (см. кодирование символов). Стандартом HTML рекомендуется использовать кодировку UTF-8 (which can represent all of Unicode) and regardless of the encoding used requires Web content to declare what encoding was used.

- -

The {{HTMLElement("meta")}} element's {{htmlattrxref("charset", "meta")}} attribute is used to specify the page's character encoding. It must be used within a {{HTMLElement("head")}} block.

- -

To specify that a page is using, for example, the UTF-8 character encoding (as per the recommendation), simply place the following line in the {{HTMLElement("head")}} block:

- -
<meta charset="utf-8">
-
- -

Details and browser internals

- -

When the encoding is declared by Web content like the HTML specification requires, Firefox will use that encoding for turning the bytes into the internal representation. Unfortunately, using UTF-8 and declaring that UTF-8 was used was not always the prevalent way of offering Web content. In the 1990s, it was common to leave the encoding undeclared and to use a region-specific encoding that wasn't able to represent all of Unicode.

- -

Firefox needs a fallback encoding that it uses for non-conforming legacy content that doesn't declare its encoding. For most locales, the fallback encoding is windows-1252 (often called ISO-8859-1), which was the encoding emitted by most Windows applications in the 1990s and a superset of the encoding emitted by most UNIX applications in the 1990s as a deployed in the America has and in Western Europe. However, there are locales where Web publishing was common already in the 1990s but the windows-1252 encoding was not suitable for the local language. In these locales, legacy content that doesn't declare its encoding is typically encoded using a legacy encoding other than windows-1252. In order to work with legacy content, some Firefox localizations need a non-windows-1252 fallback encoding.

- -

Unfortunately, this means that the Web-exposed functionality of Firefox differs by locale and it is hard to read legacy content across locales with different fallback encodings. To avoid introducing this problem in locales where Web publishing took off after the adoption of UTF-8, locales that don't have a non-windows-1252 legacy encoding arising from the practices of the 1990s, should leave the fallback encoding at windows-1252 to facilitate reading content cross-locale from the old locales whose fallback encoding is windows-1252. New-authored locale-native UTF-8 content is expected to declare its encoding, in which case the fallback encoding does not participate in the processing of content.

- -

Additionally, there is a small number of locales where in the 1990s there wasn't an obvious single region-specific encoding and heuristic detection among multiple legacy encodings was introduced to Web browsers. This has then had the effect that Web authors have depended on heuristic detection being present, so Firefox still has heuristic detection in these locales.

- -

Finding canonical encoding names

- -

The text below refers to canonical names of encodings. The canonical names are the values to the right of the equals sign in unixcharset.properties.

- -

Specifying the fallback encoding

- -

As of Firefox 28, this section is obsolete, since the preference intl.charset.default no longer exists. The mapping from locales onto fallback encodings is now built into Gecko itself.

- -

The fallback encoding is specified by the preference intl.charset.default in intl.properties. It should be set to the canonical name of the legacy encoding that users of the localizations are most likely to encounter when browsing non-conforming legacy Web content that doesn't declare its encoding. Note that the fallback encoding as defined by the previous sentence does not necessarily need to be able to represent the characters needed for the language of the localization!

- -

The fallback encoding should be left to windows-1252 for Western European locales, North, Central and South American locales, African locales, Central Asian locales and Oceanian locales. It typically needs to be set to something other than windows-1252 for Central and Eastern European locales, Middle Eastern locales and East Asian locales.

- -

In order to avoid the problem of Web authors creating new UTF-8 content without declaring that the content uses UTF-8 and in order to maximize the ability of users to read content cross-locale, do not set the fallback encoding to UTF-8 for any newly-introduced localization. Note that Firefox no longer sends the Accept-Charset HTTP header, so there is no need to consider what gets advertised in Accept-Charset when setting the fallback encoding.

- -

For locales where the fallback encoding is currently ISO-8859-1, it should be changed to windows-1252. ISO-8859-1 is decoded in the exact same way as windows-1252, but Firefox is moving to treating windows-1252 as the preferred label for this encoding in accordance with the Encoding Standard.

- -

For locales where Internet Explorer has more market share than Firefox, the fallback encoding should typically be set to the same value as in Internet Explorer. You can see the fallback encoding a particular browser has by loading a test page. (Be sure to use a browser installation that has its settings left to the defaults when investigating!)

- -

For locales where Firefox has more market share than Internet Explorer, it's probably best not to change the fallback encoding even if it doesn't follow the guidance given above. (For example, the fallback encoding for the Polish, Hungarian and Czech locales should probably continue to be ISO-8859-2 even though IE has a different fallback encoding.)

- -

When in doubt, use windows-1252 as the fallback encoding.

- -

Specifying the heuristic detection mode

- -

The heuristic detection mode is specified by the preference intl.charset.detector in intl.properties. The setting must be left blank for all locales other than Russian, Ukrainian and Japanese. Do not under any circumstances specify the "universal" detector. It is not actually universal despite its name!

- -

Exception for minority languages

- -

If the localization is for minority language and the users are typically literate in the majority language of the region and read Web content written in the majority language very often, it is appropriate to specify the fallback encoding and the heuristic detection mode to be the same as for the localization for the majority language of the region. For example, for a localization for minority language in Russia, it is appropriate to copy the settings from the Russian localization.

- -

Setting some encodings to be more easily selectable from the character encoding menu

- -

The preference intl.charsetmenu.browser.static in intl.properties makes some character encodings more easily available in the Character Encoding menu in the browser. The value should be a comma-separated list of canonical encoding names. The list should include at least the fallback encoding, windows-1252 and UTF-8. For locales where there are multiple common legacy encodings, all those encodings should be included. For example, the fallback encoding for Japanese is Shift_JIS, but there are other legacy encodings: ISO-2022-JP and EUC-JP. Therefore, it makes sense for the list to be Shift_JIS, EUC-JP, ISO-2022-JP, windows-1252, UTF-8.

diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index a8a1ddf3c5..c8f0a43894 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -2319,6 +2319,7 @@ /zh-CN/docs/Web/Guide/HTML/Tips_for_authoring_fast-loading_HTML_pages /zh-CN/docs/Learn/HTML/Howto/Author_fast-loading_HTML_pages /zh-CN/docs/Web/Guide/HTML/Using_HTML5_audio_and_video /zh-CN/docs/conflicting/Learn/HTML/Multimedia_and_embedding/Video_and_audio_content /zh-CN/docs/Web/Guide/HTML/Using_data_attributes /zh-CN/docs/Learn/HTML/Howto/Use_data_attributes +/zh-CN/docs/Web/Guide/Localizations_and_character_encodings /zh-CN/docs/orphaned/Web/Guide/Localizations_and_character_encodings /zh-CN/docs/Web/Guide/Performance/Using_web_workers /zh-CN/docs/Web/API/Web_Workers_API/Using_web_workers /zh-CN/docs/Web/Guide/Using_FormData_Objects /zh-CN/docs/Web/API/FormData/Using_FormData_Objects /zh-CN/docs/Web/HTML/Attributes/自动完成属性 /zh-CN/docs/Web/HTML/Attributes/autocomplete diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index e9d6f5f614..4240db30b9 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -31719,14 +31719,6 @@ "fantasticfears" ] }, - "Web/Guide/Localizations_and_character_encodings": { - "modified": "2020-05-07T10:52:56.537Z", - "contributors": [ - "Ende93", - "91JOJO", - "xdsnet" - ] - }, "Web/Guide/Mobile": { "modified": "2019-03-23T23:20:37.061Z", "contributors": [ @@ -50582,6 +50574,14 @@ "leegorous" ] }, + "orphaned/Web/Guide/Localizations_and_character_encodings": { + "modified": "2020-05-07T10:52:56.537Z", + "contributors": [ + "Ende93", + "91JOJO", + "xdsnet" + ] + }, "orphaned/Web/HTML/Element/command": { "modified": "2019-03-18T20:43:33.481Z", "contributors": [ diff --git a/files/zh-cn/orphaned/web/guide/localizations_and_character_encodings/index.html b/files/zh-cn/orphaned/web/guide/localizations_and_character_encodings/index.html new file mode 100644 index 0000000000..8164afecff --- /dev/null +++ b/files/zh-cn/orphaned/web/guide/localizations_and_character_encodings/index.html @@ -0,0 +1,62 @@ +--- +title: 本地化和字符编码 +slug: orphaned/Web/Guide/Localizations_and_character_encodings +tags: + - HTML + - 字符编码 +translation_of: Web/Guide/Localizations_and_character_encodings +original_slug: Web/Guide/Localizations_and_character_encodings +--- +

浏览器内部是以 Unicode 来处理文本的。然而,在将文本通过网络传递到浏览器时,是使用字节(字符编码)来表示字符的。HTML规范 推荐使用UTF-8编码(可以代表所有的Unicode),并且无论网站要使用哪种编码,都需要其声明所使用的编码类型。

+ +

在 {{HTMLElement("meta")}} 元素中的 {{htmlattrxref("charset", "meta")}} 属性被用来指明页面采用的编码。它必须在 {{HTMLElement("head")}} 定义块中使用。

+ +

例如,要指定页面正在使用UTF-8字符编码(按照建议),只需将以下行放在{{HTMLElement("head")}}标签中

+ +
<meta charset="utf-8">
+
+ +

浏览器内部细节

+ +

当 Web 内容依据 HTML 规范要求声明了编码时,Firefox将转换该编码内容到内部编码格式(声明编码->Unicode)。不幸的是,以往的Web内容并不总是使用UTF-8编码且声明为UTF-8编码。在20世纪90年代,不声明编码类型,或者使用不能代表所有Unicode的特定区域的编码来处理内容的情况都是很常见的。

+ +

对于不声明其编码,且不符合HTML规范的内容的处理,Firefox需要一个备用编码。大多数时候,备用编码是windows-1252(通常称为ISO-8859-1),这一编码在上世纪90年代大量用于部署在美国和西欧的Windows应用程序,而且它是当时大量部署的UNIX应用程序(也主要在美国和西欧)编码的超集。不过即使这一时期同样在一些地区(非美国和西欧),其网络内容中也不是采用windows-1252编码的,在这些地区,对于不声明编码的内容备用编码需要一个非windows-1252(non-windows-1252)。

+ +

不幸的是,有太多区域对应不同的备用编码(non-windows-1252),这意味着Firefox不能很好的确定那么多遗留内容不同的备用编码。为了处理这些内容,Firefox把windows-1252作为备用编码,用于旧的跨区域内容部分,并促其采用正确的地区对应备用编码。在新创建内容时,需要声明编码,而备用编码不再参与内容的处理。

+ +

此外,在上世纪90年代有少数地区,没有明显的单一的特定区域编码,从而引入了多个遗留编码到Web内容中,这使得内容展示效果依赖于启发检测到的编码设定。为此Firefox仍然在这些区域中进行启发式检测(甚至可以指定编码)。

+ +

查找编码规范名称

+ +


+ 下面的文字是指编码规范名称。规范名称是注册在unixcharset.properties(unixcharset表达式)中等号右边的值。

+ +

指定备用编码

+ +

对于 Firefox 28, 这部分内容是过时的,因为 intl.charset.default不再存在。从地区映射备用编码现在已经集成到Gecko内部。

+ +

备用编码指定在 intl.properties 下的intl.charset.default 中。它用于指定本地化传统内容将采用的编码。它应该设定为当地遇到未定义编码传统内容最可能采用的编码。注意 这里指定的备用编码不一定能够准确表示内容所需的当地语言所有本地化字符!

+ +

在西欧、北美洲、中美洲、南美洲、非洲、中亚和大洋洲等等地区,备用编码通常设置为windows-1252,但在其他地区,如中欧、东欧、中东、东亚等等地区通常需要设置为其他编码。

+ +

为了避免Web作者创造新的UTF-8的内容时没有声明内容使用UTF-8,且为了最大限度地提高用户跨区域阅读内容的能力,不设置备用编码就采用UTF-8。注意,Firefox不再发送接受字符的HTTP头( Accept-Charset ),所以设定备用编码时不需要考虑不需要考虑 Accept-Charset的内容。

+ +

对于地区后备编码目前指定为ISO-8859-1的,应该改为windows-1252。虽然ISO-8859-1编码和windows-1252编码相同。但火狐正在推动windows-1252作为这些内容在 Encoding Standard (编码规范)中的首选标准。

+ +

对于Internet Explorer拥有比Firefox更大的市场份额的区域,备用编码通常应设置为与Internet Explorer相同的值。通过加载测试页面,您可以看到特定浏览器的备用编码。(在测试时一定要使用默认设置!)

+ +

对于Firefox比Internet Explorer拥有更多市场份额的地区,最好不要更改回退编码,即使它不遵循上面给出的指导。(例如,波兰、匈牙利和捷克的地区的备用编码应该继续采用ISO-8859-2,尽管这与IE是不同的备用编码。)

+ +

有疑问时,使用windows-1252作为备用的编码。

+ +

指定启发式检测模式

+ +

启发式检测模式是由intl.properties中偏好intl.charset.detector指定。除了俄语、乌克兰语和日语以外,所有区域的设置必须留空。在任何情况下都不要指定 "universal" (“万能”)探测器。尽管它的名字并不普遍!

+ +

少数民族语言例外

+ +

如果用户本身可采用少数民族语言和文字,但他通常使用区域通用语言,这时适当的指定备用编码和启发式检测模式需要与所处广大的区域的语言定位相同。例如,对于俄罗斯的少数民族语言本地化,复制来自俄罗斯本地化的设置是合适的。

+ +

设置一些更容易从菜单选择的字符编码

+ +

intl.properties中的 intl.charsetmenu.browser.static 可以标记一些编码,它们出现在浏览器编码选择菜单中。该值是一个逗号分隔的规范编码名称列表。清单应至少包括备用编码,windows-1252和UTF-8编码。对于可能有多个遗留编码的地区,这些编码都应被包括。例如,在日本设置 Shift_JIS为备用编码,但也有其他的传统编码: ISO-2022-JP和EUC-JP。因此, intl.charsetmenu.browser.static应该设置为" Shift_JIS, EUC-JP, ISO-2022-JP, windows-1252, UTF-8"。

diff --git a/files/zh-cn/web/guide/localizations_and_character_encodings/index.html b/files/zh-cn/web/guide/localizations_and_character_encodings/index.html deleted file mode 100644 index 5a5c2169e2..0000000000 --- a/files/zh-cn/web/guide/localizations_and_character_encodings/index.html +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: 本地化和字符编码 -slug: Web/Guide/Localizations_and_character_encodings -tags: - - HTML - - 字符编码 -translation_of: Web/Guide/Localizations_and_character_encodings ---- -

浏览器内部是以 Unicode 来处理文本的。然而,在将文本通过网络传递到浏览器时,是使用字节(字符编码)来表示字符的。HTML规范 推荐使用UTF-8编码(可以代表所有的Unicode),并且无论网站要使用哪种编码,都需要其声明所使用的编码类型。

- -

在 {{HTMLElement("meta")}} 元素中的 {{htmlattrxref("charset", "meta")}} 属性被用来指明页面采用的编码。它必须在 {{HTMLElement("head")}} 定义块中使用。

- -

例如,要指定页面正在使用UTF-8字符编码(按照建议),只需将以下行放在{{HTMLElement("head")}}标签中

- -
<meta charset="utf-8">
-
- -

浏览器内部细节

- -

当 Web 内容依据 HTML 规范要求声明了编码时,Firefox将转换该编码内容到内部编码格式(声明编码->Unicode)。不幸的是,以往的Web内容并不总是使用UTF-8编码且声明为UTF-8编码。在20世纪90年代,不声明编码类型,或者使用不能代表所有Unicode的特定区域的编码来处理内容的情况都是很常见的。

- -

对于不声明其编码,且不符合HTML规范的内容的处理,Firefox需要一个备用编码。大多数时候,备用编码是windows-1252(通常称为ISO-8859-1),这一编码在上世纪90年代大量用于部署在美国和西欧的Windows应用程序,而且它是当时大量部署的UNIX应用程序(也主要在美国和西欧)编码的超集。不过即使这一时期同样在一些地区(非美国和西欧),其网络内容中也不是采用windows-1252编码的,在这些地区,对于不声明编码的内容备用编码需要一个非windows-1252(non-windows-1252)。

- -

不幸的是,有太多区域对应不同的备用编码(non-windows-1252),这意味着Firefox不能很好的确定那么多遗留内容不同的备用编码。为了处理这些内容,Firefox把windows-1252作为备用编码,用于旧的跨区域内容部分,并促其采用正确的地区对应备用编码。在新创建内容时,需要声明编码,而备用编码不再参与内容的处理。

- -

此外,在上世纪90年代有少数地区,没有明显的单一的特定区域编码,从而引入了多个遗留编码到Web内容中,这使得内容展示效果依赖于启发检测到的编码设定。为此Firefox仍然在这些区域中进行启发式检测(甚至可以指定编码)。

- -

查找编码规范名称

- -


- 下面的文字是指编码规范名称。规范名称是注册在unixcharset.properties(unixcharset表达式)中等号右边的值。

- -

指定备用编码

- -

对于 Firefox 28, 这部分内容是过时的,因为 intl.charset.default不再存在。从地区映射备用编码现在已经集成到Gecko内部。

- -

备用编码指定在 intl.properties 下的intl.charset.default 中。它用于指定本地化传统内容将采用的编码。它应该设定为当地遇到未定义编码传统内容最可能采用的编码。注意 这里指定的备用编码不一定能够准确表示内容所需的当地语言所有本地化字符!

- -

在西欧、北美洲、中美洲、南美洲、非洲、中亚和大洋洲等等地区,备用编码通常设置为windows-1252,但在其他地区,如中欧、东欧、中东、东亚等等地区通常需要设置为其他编码。

- -

为了避免Web作者创造新的UTF-8的内容时没有声明内容使用UTF-8,且为了最大限度地提高用户跨区域阅读内容的能力,不设置备用编码就采用UTF-8。注意,Firefox不再发送接受字符的HTTP头( Accept-Charset ),所以设定备用编码时不需要考虑不需要考虑 Accept-Charset的内容。

- -

对于地区后备编码目前指定为ISO-8859-1的,应该改为windows-1252。虽然ISO-8859-1编码和windows-1252编码相同。但火狐正在推动windows-1252作为这些内容在 Encoding Standard (编码规范)中的首选标准。

- -

对于Internet Explorer拥有比Firefox更大的市场份额的区域,备用编码通常应设置为与Internet Explorer相同的值。通过加载测试页面,您可以看到特定浏览器的备用编码。(在测试时一定要使用默认设置!)

- -

对于Firefox比Internet Explorer拥有更多市场份额的地区,最好不要更改回退编码,即使它不遵循上面给出的指导。(例如,波兰、匈牙利和捷克的地区的备用编码应该继续采用ISO-8859-2,尽管这与IE是不同的备用编码。)

- -

有疑问时,使用windows-1252作为备用的编码。

- -

指定启发式检测模式

- -

启发式检测模式是由intl.properties中偏好intl.charset.detector指定。除了俄语、乌克兰语和日语以外,所有区域的设置必须留空。在任何情况下都不要指定 "universal" (“万能”)探测器。尽管它的名字并不普遍!

- -

少数民族语言例外

- -

如果用户本身可采用少数民族语言和文字,但他通常使用区域通用语言,这时适当的指定备用编码和启发式检测模式需要与所处广大的区域的语言定位相同。例如,对于俄罗斯的少数民族语言本地化,复制来自俄罗斯本地化的设置是合适的。

- -

设置一些更容易从菜单选择的字符编码

- -

intl.properties中的 intl.charsetmenu.browser.static 可以标记一些编码,它们出现在浏览器编码选择菜单中。该值是一个逗号分隔的规范编码名称列表。清单应至少包括备用编码,windows-1252和UTF-8编码。对于可能有多个遗留编码的地区,这些编码都应被包括。例如,在日本设置 Shift_JIS为备用编码,但也有其他的传统编码: ISO-2022-JP和EUC-JP。因此, intl.charsetmenu.browser.static应该设置为" Shift_JIS, EUC-JP, ISO-2022-JP, windows-1252, UTF-8"。

-- cgit v1.2.3-54-g00ecf