URI共通構文(2)

広告

広告

原文

最終更新
2006-04-14T01:01:00+09:00
この記事のURI参照
https://www.7key.jp/rfc/2396/rfc2396_2.html#source

URI共通構文(和訳)

最終更新
2006-09-25T00:00:00+09:00
この記事のURI参照
https://www.7key.jp/rfc/2396/rfc2396_2.html#translation

2. URI Characters and Escape Sequences

   URI consist of a restricted set of characters, primarily chosen to
   aid transcribability and usability both in computer systems and in
   non-computer communications. Characters used conventionally as
   delimiters around URI were excluded.  The restricted set of
   characters consists of digits, letters, and a few graphic symbols
   were chosen from those common to most of the character encodings and
   input facilities available to Internet users.

      uric          = reserved | unreserved | escaped

URIは、コンピュータを介する場合であろうとなかろうと、転記をし易く使い勝手の良いことを主眼に選ばれた文字の集合から構成される。まず、URIの前後で区切り文字として習慣的に使われる文字は排除されている。また、数字、英字、いくつかの記号からなる制限付きの文字列は、多くの文字コードで共通し、そしてインターネット利用者が用意に入力をすることができる文字の中から選択されている。

   Within a URI, characters are either used as delimiters, or to
   represent strings of data (octets) within the delimited portions.
   Octets are either represented directly by a character (using the US-
   ASCII character for that octet [ASCII]) or by an escape encoding.
   This representation is elaborated below.

URIの中では、文字は区切り文字として使われるか、又はそれにより区切られた個所の中で文字列を構成するデータを表すために使われる。オクテットは文字(そのオクテットを表すUS-ASCII文字)によって直接表現されるか、エスケープ符号化されるかのどちらかであり、この表現方法については後に詳しく説明する。

2.1 URI and non-ASCII characters

   The relationship between URI and characters has been a source of
   confusion for characters that are not part of US-ASCII. To describe
   the relationship, it is useful to distinguish between a "character"
   (as a distinguishable semantic entity) and an "octet" (an 8-bit
   byte). There are two mappings, one from URI characters to octets, and
   a second from octets to original characters

       URI character sequence->octet sequence->original character sequence:

URIと文字との関連は、US-ASCIIに含まれない文字のために混乱を招くこととなった。この関連性について触れるために、区別可能な意味を持つ要素である文字と8bitを意味するオクテットの区別を明確にする必要がある。以下は2つの写像である。最初はURI文字からオクテットへの写像、2つ目はオクテットから元となる文字への写像である。

   A URI is represented as a sequence of characters, not as a sequence
   of octets. That is because URI might be "transported" by means that
   are not through a computer network, e.g., printed on paper, read over
   the radio, etc.

URIは文字列として表現されるのであり、オクテット列として表現されるわけではない。これは、URIがコンピュータネットワークを介さない方法――例えば紙面やラジオの読み上げなど――で伝送されることもあるからだ。

   A URI scheme may define a mapping from URI characters to octets;
   whether this is done depends on the scheme. Commonly, within a
   delimited component of a URI, a sequence of characters may be used to
   represent a sequence of octets. For example, the character "a"
   represents the octet 97 (decimal), while the character sequence "%",
   "0", "a" represents the octet 10 (decimal).

URIスキームは、URI文字からオクテット文字への写像を定義することもある。定義されるか否かはスキームに依存する。一般に、URIの区切り文字で分けられたコンポーネント中では、文字列はオクテット列の表現として用いられる。例えば、文字"a"はオクテット97(10進法)を表し、"%"-"0"-"a"からなる文字列はオクテット10(10進法)を表す。

   There is a second translation for some resources: the sequence of
   octets defined by a component of the URI is subsequently used to
   represent a sequence of characters. A 'charset' defines this mapping.
   There are many charsets in use in Internet protocols. For example,
   UTF-8 [UTF-8] defines a mapping from sequences of octets to sequences
   of characters in the repertoire of ISO 10646.

リソースによっては2回変換が行われることとなる。URIのコンポーネントで定義されたオクテット列が、文字列の表現の後に用いられる場合がそれであり、文字コードによってこの写像は定義されている。インターネットプロトコルでは多くの文字コードが使われており、例えば、UTF-8[UTF-8]はオクテット列から ISO 10646 に含まれる文字列への写像を定義している。

   In the simplest case, the original character sequence contains only
   characters that are defined in US-ASCII, and the two levels of
   mapping are simple and easily invertible: each 'original character'
   is represented as the octet for the US-ASCII code for it, which is,
   in turn, represented as either the US-ASCII character, or else the
   "%" escape sequence for that octet.

もっとも単純な例は、元の文字列が US-ASCII で定義されている文字のみを含み、2段階の写像が単純で簡単な逆写像の場合である。それぞれの元になる文字はその文字に対応する US-ASCII コードを示すオクテットとして表され、更にこのオクテットは、US-ASCII 文字かそのオクテットを表す"%"でエスケープされた文字として表される。

   For original character sequences that contain non-ASCII characters,
   however, the situation is more difficult. Internet protocols that
   transmit octet sequences intended to represent character sequences
   are expected to provide some way of identifying the charset used, if
   there might be more than one [RFC2277].  However, there is currently
   no provision within the generic URI syntax to accomplish this
   identification. An individual URI scheme may require a single
   charset, define a default charset, or provide a way to indicate the
   charset used.

しかし、元の文字列が非ASCII文字を含んでいる場合は多少の困難を伴うこととなる。文字列を表現することを想定してオクテット列を伝送するインターネットプロトコルでは、用いられる文字コードが複数あると考えられる場合、その文字コードを識別する何らかの方法が提供されているはずである[RFC 2277]。しかし現在、一般的なURIの構文にはこの文字コードを識別する方法は準備されていない。したがってそれぞれのURIスキームは、単一の文字コードを要求するか、文字コードの規定値の定義を要求するか、使う文字コードを示す方法の提供を要求する場合がある。

   It is expected that a systematic treatment of character encoding
   within URI will be developed as a future modification of this
   specification.

当仕様書が将来的に修正されることを前提に、URIの中で文字コードを系統的に処理する方法が開発されることを期待する。

2.2. Reserved Characters

   Many URI include components consisting of or delimited by, certain
   special characters.  These characters are called "reserved", since
   their usage within the URI component is limited to their reserved
   purpose.  If the data for a URI component would conflict with the
   reserved purpose, then the conflicting data must be escaped before
   forming the URI.

コンポーネントを構成する、もしくは区切り文字として使われる何らかの特殊文字がURIに含まれることは珍しくない。これらの特殊文字は、その文字が持つ目的を果たすためにURIコンポーネントの中での使用に制限がなされており、そのため予約文字と呼ばれている。URIコンポーネントの持つデータが予約文字を含む場合、URIを形成する前にその文字はエスケープされなければならない。

      reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                    "$" | ","

   The "reserved" syntax class above refers to those characters that are
   allowed within a URI, but which may not be allowed within a
   particular component of the generic URI syntax; they are used as
   delimiters of the components described in Section 3.

上記の予約文字構文クラスは、URIに含めても良いが、一般的なURI構文の特殊なコンポーネントの中での使用は認められていない文字を指している。これらの文字は3. URI構文の構成要素で紹介されるコンポーネントの区切り文字として使われるものである。

   Characters in the "reserved" set are not reserved in all contexts.
   The set of characters actually reserved within any given URI
   component is defined by that component. In general, a character is
   reserved if the semantics of the URI changes if the character is
   replaced with its escaped US-ASCII encoding.

予約文字が全ての文脈で予約されているわけではない。URIコンポーネントの実際の予約文字は、そのコンポーネントの中で定義されている。一般的に、ある文字を US-ASCII 符号化でエスケープした際にそのURIの指し示す意味が変わる場合、その文字は予約されていると言える。

2.3. Unreserved Characters

   Data characters that are allowed in a URI but do not have a reserved
   purpose are called unreserved.  These include upper and lower case
   letters, decimal digits, and a limited set of punctuation marks and
   symbols.

      unreserved  = alphanum | mark

      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"

URIで用いることができ、予約目的のないデータ文字を非予約文字(unreserved)と呼ぶ。非予約文字には、大文字と小文字のアルファベット、数字、句読点や記号の一部が含まれる。

   Unreserved characters can be escaped without changing the semantics
   of the URI, but this should not be done unless the URI is being used
   in a context that does not allow the unescaped character to appear.

非予約文字は、URIの意味を変えることなくエスケープ可能だが、その文字の使用が認められていない文脈以外で無用にエスケープすべきではない。

2.4. Escape Sequences

   Data must be escaped if it does not have a representation using an
   unreserved character; this includes data that does not correspond to
   a printable character of the US-ASCII coded character set, or that
   corresponds to any US-ASCII character that is disallowed, as
   explained below.

非予約文字を使って表すことができないデータはエスケープしなければならない。US-ASCII文字コードセットに含まれない印刷文字や、使用が認められていないUS-ASCII文字がこれに当る。

2.4.1. Escaped Encoding
   An escaped octet is encoded as a character triplet, consisting of the
   percent character "%" followed by the two hexadecimal digits
   representing the octet code. For example, "%20" is the escaped
   encoding for the US-ASCII space character.

      escaped     = "%" hex hex
      hex         = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                            "a" | "b" | "c" | "d" | "e" | "f"

エスケープされたオクテットは3つの連なる文字列――パーセント文字"%"の後にオクテットコードを表す2つの16進数字を付ける構成――としてエンコードされる。例えば、%20は US-ASCII の空白文字をエスケープエンコードしたものである。

2.4.2. When to Escape and Unescape
   A URI is always in an "escaped" form, since escaping or unescaping a
   completed URI might change its semantics.  Normally, the only time
   escape encodings can safely be made is when the URI is being created
   from its component parts; each component may have its own set of
   characters that are reserved, so only the mechanism responsible for
   generating or interpreting that component can determine whether or
   not escaping a character will change its semantics. Likewise, a URI
   must be separated into its components before the escaped characters
   within those components can be safely decoded.

エスケープをするかしないかにより完成したURIの意味が変わるかもしれないので、URIは常にエスケープされた形式となる。通常、エスケープ符号化を安全に行えるのは、URIが作成される途中だけである。それは、各コンポーネントは独自の予約文字集合を有する場合があるため、そのコンポーネントの生成と解釈に責任を持つ機構にしか、エスケープすることによってその意味が変わるかどうかの判断はできないからである。同様に、URIはコンポーネント内のエスケープされた文字を安全に複合化する前に、それぞれのコンポーネントへ分割されていなければならない。

   In some cases, data that could be represented by an unreserved
   character may appear escaped; for example, some of the unreserved
   "mark" characters are automatically escaped by some systems.  If the
   given URI scheme defines a canonicalization algorithm, then
   unreserved characters may be unescaped according to that algorithm.
   For example, "%7e" is sometimes used instead of "~" in an http URL
   path, but the two are equivalent for an http URL.

場合によっては、非予約文字がエスケープされるかもしれない。例えば、システムによっては予約されていない記号が自動的にエスケープされる場合がある。与えられたURIスキームが正当なアルゴリズムを定義するのであれば、非予約文字がそのアルゴリズムに従ってアンエスケープされる場合もある。例えば、"%7E"は http のURLで "~" の代わりに使われるが、それは http の URL でこの2つは同じ意味を持つためである。

   Because the percent "%" character always has the reserved purpose of
   being the escape indicator, it must be escaped as "%25" in order to
   be used as data within a URI.  Implementers should be careful not to
   escape or unescape the same string more than once, since unescaping
   an already unescaped string might lead to misinterpreting a percent
   data character as another escaped character, or vice versa in the
   case of escaping an already escaped string.

パーセント文字"%"はエスケープのために予約されているため、URIのデータ中で使われる場合は常に"%25"とエスケープされなければならない。実装の際は、同じ文字列を複数回エスケープ又はアンエスケープしないよう注意しなければならない。これは、既にアンエスケープされている文字列をアンエスケープすることにより、パーセント文字を含む文字列が別のエスケープされた文字として誤って解釈される恐れがあるためであり、エスケープされている文字を更にエスケープする場合も同様である。

2.4.3. Excluded US-ASCII Characters
   Although they are disallowed within the URI syntax, we include here a
   description of those US-ASCII characters that have been excluded and
   the reasons for their exclusion.

こちらで挙げる US-ASCII 文字はURI構文での使用が認められていないが、その種類と除外理由について説明を加える。

   The control characters in the US-ASCII coded character set are not
   used within a URI, both because they are non-printable and because
   they are likely to be misinterpreted by some control mechanisms.

   control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>

US-ASCII 文字コードセットの制御文字をURIの中で使ってはならない。それらは印刷不可能であり、更に制御機構によっては誤った解釈をされる恐れがあるからである。

   The space character is excluded because significant spaces may
   disappear and insignificant spaces may be introduced when URI are
   transcribed or typeset or subjected to the treatment of word-
   processing programs.  Whitespace is also used to delimit URI in many
   contexts.

   space       = <US-ASCII coded character 20 hexadecimal>

URIを転記する、入力する、ワープロソフトで処理を行うといった際に、意味のある空白を逃したり無意味な空白が挿入される恐れがあるため、空白文字は除外されている。また、文脈の中でURIを区切る目的に空白を使用することが多いのも除外された理由の一つである。

   The angle-bracket "<" and ">" and double-quote (") characters are
   excluded because they are often used as the delimiters around URI in
   text documents and protocol fields.  The character "#" is excluded
   because it is used to delimit a URI from a fragment identifier in URI
   references (Section 4). The percent character "%" is excluded because
   it is used for the encoding of escaped characters.

   delims      = "<" | ">" | "#" | "%" | <">

山括弧"<"と">"、ダブルクオーテーション(")が除外されたのは、これらがテキスト文書やプロトコルフィールドの中でURIの前後の区切り文字として使われるためである。"#"が除外されたのは、この文字がURIの示すリソース内を参照するフラグメント識別子とURIを区切るために使われるためである(4. URI参照)。パーセント文字"%"が除外されたのは、この文字がエスケープ符号化に使われるためである。

   Other characters are excluded because gateways and other transport
   agents are known to sometimes modify such characters, or they are
   used as delimiters.

   unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"

その他の文字が除外されたのは、ゲートウェイや他の転送エージェントによってはこれらの文字を変更したり、デリミタとして使ったりするものがあるためである。

   Data corresponding to excluded characters must be escaped in order to
   be properly represented within a URI.

URI中で適切に表されるよう、除外文字とされているデータはエスケープされなければならない。

広告

Copyright (C) 2006 七鍵 key@do.ai 初版:2006年04月14日 最終更新:2006年09月25日