文字エンコードの設定

This page explains the encoding settings that are applicable in Confluence and how they relate to application behaviour.

文字エンコードによる問題を回避するには、システムの様々なコンポーネント間で使用されるエンコードが同じであることを確認します。一般的に、すべての文字エンコードを常に UTF-8 に設定します

  • Confluence character encoding  – described below.

Confluence 文字エンコードの設定

既定では、Confluence はページの配信に UTF-8 文字エンコードを使用します。

注意: 文字エンコードは変更可能ですが、行っていることに確信がないかぎり、現状のままにすることをお勧めします。

要約: Confluence 文字エンコードを変更すると、HTTP 要求および応答のエンコードとエクスポートやVelocity テンプレートで使用されるファイルシステムのエンコードが変更されます。

 

UI を通じて Confluence 文字エンコードを変更する手順

  1. Choose the cog icon , then choose General Configuration under Confluence Administration

  2. 左側のパネルにある一般設定を選択する。

  3. 編集を選択する。

  4. 選択した新しい文字エンコードをエンコードの横のテキストボックスに入力します。 

  5. 保存を選択します 。

Note: At runtime, the character encoding is available in Settings.defaultEncoding.

文字エンコードに関する詳細

Confluence にとって文字エンコードが重要になる場所が3つあります。

  1. データベースエンコード - 通常、最も重要です。ほぼすべてのユーザーデータが保存される場所です。
  2. ファイルシステムエンコード - 添付ファイルの保存場所 (pre-2.2)、Velocity テンプレートの読み取りおよびエクスポート済みファイルの書き込みのために重要です。
  3. HTTP 要求および応答のエンコード - フォーム構文解析、ブラウザーによるレンダリングの修正およびエンコード済み URL のブラウザー変換処理のために重要です。

一般的に、問題は Confluence が上記のエンコードの1つと実際のエンコードが異なると認識した場合に生じます。たとえば、Confluence はデータベースが実際には UTF-8 エンコードを使用しているにもかかわらず、 ISO-8859-1 エンコードを使用していると認識する可能性があります。

ある場合において (Microsoft Windows など)、 完全には Unicode ファイルシステムを使用できない可能性があります (つまり、既定の Windows インストールでは Unicode ファイル名が適切にサポートされていません)。その場合、他の2つのために UTF-8 を維持し、国際添付ファイル (pre-2.2) や、国際データのバックアップおよび復元に関してオペレーティングシステムが制約される場合があることに留意します。

Java の文字エンコード

Java always uses the multibyte UTF-16 character encoding for all String data*. This means that each of the encodings above defines how, at that particular point, characters are converted to and from Java's native UTF-16 format into some other format that the browser, filesystem or database might understand.

要求が Confluence に着信すると、要求のエンコードが UTF-16 に変換されます。次に、そのデータをデータベースに保存します。このとき、UTF-16 からデータベースのエンコードに変換されます。データベースから情報を取得して、応答をブラウザーに送信するプロセスは、これを逆方向にたどることになります。

*A char represents single Unicode code point from the Base Multilingual Plane (BMP), encoded as UTF-16. Multiple chars are used as surrogate pairs for characters beyond U+FFFF.

Confluence の文字エンコード

Confluence 文字エンコードはシステムの次の部分で使用されます。

  • ConfluenceWebWorkConfiguration sets webwork.i18n.encoding to the this encoding, which WebWork uses in the response Content-Type header.
  • AbstractEncodingFilter は HTTP 要求エンコードをこのエンコードに設定します。クライアントからの Content-Type ヘッダーには使用されているエンコードが含まれているはずなので、これは不要と考えられます。 これは、フォームの送信やファイルのアップロードに影響を与えます。
  • VelocityUtils は、ディスクからテンプレートを読み取るときにこのエンコードを使用して Velocity テンプレートを読み取ります。
  • AbstractXmlExporter は、このエンコードを使用して出力を作成します。
  • GeneralUtil は、URLEncode および URLDecode を実行するときこのエンコードを使用します。異なるブラウザーは、URL で異なる文字セットをサポートしているため、これによりどの程度の利点が得られるかは不明です。

See Configuring Confluence Character Encoding (described above.)

データベースのエンコード

The database encoding is the responsibility of your JDBC drivers. The drivers are responsible for reading and writing from the database in its native encoding and translating this data to and from Java Strings (which are UTF-16). For some drivers, such as MySQL, you must set Unicode encoding explicitly in the JDBC URL. For others, the driver is smart enough to determine the database encoding automatically.

Ideally, your database itself should be in a Unicode encoding (and we recommend doing this for the simplest configuration), but that is not necessary as long as:

  • データベースのエンコードが Confluence に保存するすべての文字をサポートしている
  • JDBC ドライバーがデータベースのエンコードと UTF-16 間の変換を正しく実行できる

See Configuring Database Character Encoding.

ファイルシステムのエンコード

ファイルシステムのエンコードは Confluence によりほとんど無視されます。ただし、上記の設定が関与する場合 (エクスポート、Velocity) は例外です。添付ファイルがアップロードされると、バイトストリームとしてファイルシステムに直接書き込まれます。ダウンロードされる場合も同様です。InputStream ファイルからのバイトが HTTP 応答に直接書き込まれます。

In some places in Confluence, we use the default filesystem encoding as determined by the JVM and stored in the file.encoding system property (it can be overridden by setting this property at startup). This encoding is used by the Java InputStreamReader and InputStreamWriter classes by default. This encoding should probably never be used; for consistent results across all filesystem access we should be using the encoding set in the General Configuration.

ファイルシステムからのデータの読み取りまたはファイルシステムへのデータの書き込みに使用されるエンコードを明示的ハードコード化する場合もあります。2つの重要な例を以下に示します。

  • ISO-8859-1 で知られている Mbox メールボックスのインポート。
  • Confluence Bandana config ファイルは常に UTF-8 で保存されます。

Some application servers, Tomcat for example, have an encoding setting that modifies Confluence URLs before they reach the application. This can prevent access to international pages and attachments (really anything with international characters in the URL). See configuring your Application Server URL encoding.

文字エンコードの問題

Confluence が上記のいずれかのエンコードについて誤認をした場合、それが以下のように様々な形で現れます。

  1. 不正なデータベースエンコード - ユーザーデータが保存やデータベースからの復元の過程で破損します。多くの場合、これは遅れて生じます。というのも、データはデータベースに書き込まれているとおりにキャッシュされるため、後になって初めてデータベースから破損したコピーを取得することになります。
  2. 不正な/非 Unicode のファイルシステムエンコード - 国際ファイル名によって添付ファイルのダウンロード/アップロード/削除 (pre-2.2) が中断します。 エクスポートは国際コンテンツまたは添付ファイルが含まれている場合中断します。
  3. 不正な HTTP エンコード - ブラウザーにより不正なエンコードが選択された場合、文字のレンダリングが正しく行われません。ブラウザーのエンコードを変更すると、ページのレンダリングが正しく行われます。非 ASCII 文字が含まれるページまたは添付ファイルへのリンク時にURL が壊れます。

See Troubleshooting Character Encodings.

注意

最終更新日: 2015 年 12 月 2 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.