プロが教える店舗&オフィスのセキュリティ対策術

Unicode規定の Zs (space separator) とは

ECMA262 Edition 5 規定の String.prototype.trim() を未対応ブラウザ用に実装しようとしています。
仕様には「WhiteSpace, LineTerminator を取り除く」との記述がありました。

-------
15.5.4.20 String.prototype.trim()
...(中略)...
3. Let T be a String value that is a copy of S with both leading and trailing white space removed. The definition of white space is the union of WhiteSpace and LineTerminator.
http://www.ecma-international.org/publications/s …
-------

WhiteSpace, LineTerminator はそれぞれ「7.2 White Space」「7.3 Line Terminators」で定義されており、概ね理解しましたが、WhiteSpaceで定義されている「Zs」の文字が何であるか、で詰まりました。
Zs は表で記述されていますが、該当部だけ引用すると次のように書かれています。
(表をテキストで書くのは難しいのでフォーマットを変えています)

-------
7.2 White Space
...(中略)...
[Code Unit Value] Other category "Zs"
[Name] Any other Unicode "space separator"
[Formal Name] <USP>

ECMAScript implementations must recognize all of the white space characters defined in Unicode 3.0.
Later editions of the Unicode Standard may define other white space characters.
ECMAScript implementations may recognize white space characters from later edition of the Unicode Standard.
http://www.ecma-international.org/publications/s …
-------

機械翻訳を頼りに翻訳してみたところでは、「Unicode 3.0 定義の空白文字」と「最新の Unicode 定義の空白文字」を認識しなければならない、と読めました。

Unicode Consortium
http://www.unicode.org/

公式サイトらしき場所は発見しましたが、ここからどこを読めば Zs (space separator) が確認できるのか、がわかりません…。
(ぐぐってみると、それらしき情報がHITするのですが、できれば公式文書で確認したいと思っています。)

JavaScript, Regex, and Unicode
http://blog.stevenlevithan.com/archives/javascri …
Unicode Characters in the 'Separator, Space' Category
http://www.fileformat.info/info/unicode/category …

unicode.org のどこに Zs (space separator) に関する記述があるのでしょうか?

# 英語サイトに関する質問なので [英語] カテゴリにすべきか迷いましたが、内容は専門的な事なので [JavaScript] カテゴリとしました。
# 問題があるようでしたら、別の形で再質問したいと思います。

A 回答 (1件)

カテゴリ Zs は早いはなしが「空白文字」のようですね (

http://www.unicode.org/versions/Unicode5.2.0/ch0 … ). どの文字が Zs であるかはプロパティリスト (http://www.unicode.org/Public/5.2.0/ucd/PropList … ) を探せば書いてあったりします.

参考URL:http://www.unicode.org/Public/5.2.0/ucd/PropList …
    • good
    • 0
この回答へのお礼

ありがとうございます。
英語への苦手意識がまだ抜けていないようで、とても助かりました。

次のように理解しました。

----------
// Unicode 5.2.0 Property-List ( http://www.unicode.org/Public/5.2.0/ucd/PropList … )
var White_Space = {
   Cc: '\u0009-\u000D\u0085',                   // Other, control
   Zs: '\u0020\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000', // Separator, space
   Zl: '\u2028',                          // Separator, line
   Zp: '\u2029'                          // Separator, paragraph
  };
----------

* アクセス

** ch04.pdf へのアクセス ( http://www.unicode.org/versions/Unicode5.2.0/ch0 … )
[The Unicode Standard] -> [Latest Version] -> [4 Character Properties]

** ch06.pdf へのアクセス ( http://www.unicode.org/versions/Unicode5.2.0/ch0 … )
[The Unicode Standard] -> [Latest Version] -> [6 Writing Systems and Punctuation]

** PropList.txt へのアクセス ( http://www.unicode.org/Public/5.2.0/ucd/PropList … )
[The Unicode Standard] -> [Unicode Character Database] -> http://www.unicode.org/Public/5.2.0/ -> ucd/ -> PropList.txt


* 参考資料

------
4.5 General Category―Normative
... (中略) ...
Table 4-9. General Category
+-----------------------------+
| Zs = Separator, space    |
| Zl = Separator, line    |
| Zp = Separator, paragraph  |
+-----------------------------+
http://www.unicode.org/versions/Unicode5.2.0/ch0 …
------

------
6.2 General Punctuation
... (中略) ...
Table 6-2. Unicode Space Characters
+--------+------------------+
| Code  | Name       |
+--------+------------------+
| U+0020 | SPACE      |
| U+00A0 | No-BREAK SPACE  |
| U+1680 | OGHAM SPACE MARK |
| ...  | ...       |
+--------+------------------+
http://www.unicode.org/versions/Unicode5.2.0/ch0 …
------

お礼日時:2010/08/04 05:30

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!