Understanding Zs (space separator) in Unicode

このQ&Aのポイント
  • In JavaScript, the Zs (space separator) is a Unicode character defined in the WhiteSpace category.
  • ECMA262 Edition 5 introduced the String.prototype.trim() method, which removes leading and trailing white space, including Zs characters.
  • To find the definition of Zs (space separator) in Unicode, you can refer to the official Unicode Consortium website.
回答を見る
  • ベストアンサー

Unicode規定の Zs (space separator) とは

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/standards/Ecma-262.htm ------- 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/standards/Ecma-262.htm ------- 機械翻訳を頼りに翻訳してみたところでは、「Unicode 3.0 定義の空白文字」と「最新の Unicode 定義の空白文字」を認識しなければならない、と読めました。 Unicode Consortium http://www.unicode.org/ 公式サイトらしき場所は発見しましたが、ここからどこを読めば Zs (space separator) が確認できるのか、がわかりません…。 (ぐぐってみると、それらしき情報がHITするのですが、できれば公式文書で確認したいと思っています。) JavaScript, Regex, and Unicode http://blog.stevenlevithan.com/archives/javascript-regex-and-unicode Unicode Characters in the 'Separator, Space' Category http://www.fileformat.info/info/unicode/category/Zs/list.htm unicode.org のどこに Zs (space separator) に関する記述があるのでしょうか? # 英語サイトに関する質問なので [英語] カテゴリにすべきか迷いましたが、内容は専門的な事なので [JavaScript] カテゴリとしました。 # 問題があるようでしたら、別の形で再質問したいと思います。

質問者が選んだベストアンサー

  • ベストアンサー
  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.1

カテゴリ Zs は早いはなしが「空白文字」のようですね (http://www.unicode.org/versions/Unicode5.2.0/ch06.pdf ). どの文字が Zs であるかはプロパティリスト (http://www.unicode.org/Public/5.2.0/ucd/PropList.txt ) を探せば書いてあったりします.

参考URL:
http://www.unicode.org/Public/5.2.0/ucd/PropList.txt
think49
質問者

お礼

ありがとうございます。 英語への苦手意識がまだ抜けていないようで、とても助かりました。 次のように理解しました。 ---------- // Unicode 5.2.0 Property-List ( http://www.unicode.org/Public/5.2.0/ucd/PropList.txt ) 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/ch04.pdf ) [The Unicode Standard] -> [Latest Version] -> [4 Character Properties] ** ch06.pdf へのアクセス ( http://www.unicode.org/versions/Unicode5.2.0/ch06.pdf ) [The Unicode Standard] -> [Latest Version] -> [6 Writing Systems and Punctuation] ** PropList.txt へのアクセス ( http://www.unicode.org/Public/5.2.0/ucd/PropList.txt ) [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/ch04.pdf ------ ------ 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/ch06.pdf ------

関連するQ&A

  • スペースを含めた文字列の検索

    大変お世話になっております。 文字列を検索するプログラムを作っていたのですが、スペースを含んだ検索がうまくいきません。単語自体を探し当てる事は出来るのですが、「ve p」のようなスペースを含めて検索した時にはたとえそれがテキストに含まれていたとしても探し当てられないんです。 スペースを含めても探し当てられる方法を教えていただけると大変助かります。 よろしくお願いいたします。 サンプル input.txt 「My name is Java and I love programming」 ------------------------------ import java.io.*; import java.util.*; class Search{ public static void main(String[] args) throws IOException, InterruptedException{ FileReader reader = new FileReader("input.txt"); Scanner in = new Scanner(reader); int n = 0; int noLines = 0; String s = ""; System.out.println("Please insert a pattern name for searching:"); BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); String target = console.readLine(); outerLoop: while(in.hasNextLine()) { s = "" + in.nextLine(); noLines ++; Scanner in2 = new Scanner(s); while(in2.hasNext()){ if(target.equals(in2.next())){ System.out.println("Pattern '" + target + "' is found at the line of " + noLines); break outerLoop; }       }     }  } }

    • ベストアンサー
    • Java
  • 経済英語の訳をお願いできますか?

    下記の部分を教えていただけると助かります・・・。お願いします。 The information on these many companies came primarily from readily available materials such as annual and other company reports, government publications, articles in periodicals, and occasionally business histories and biographies. In eighteen of the more significant of these companies, interviews with senior executives helped supplement the printed record. The far more detailed analyses of organizational innovation at du Pont, General Motors, Standard Oil (New Jersey), and Sears, Roebuck were based, on the other hand, largely on internal company records-business correspondence, reports, memoranda, minutes of meetings, and the like. These historical documents were supplemented by interviews with men who had participated in the oraganizational changes.

  • よろしくお願いします

    Last year, she bought a new home and recruited me to help her move. I pitched in but also gave her space to deal with the masses of shopping bags that had never been unpacked full of duplicate bags of chips and other storage bags, gave her spaceとはどういうことでしょうか?あと、duplicate bags of chipsの意味を教えてください。よろしくお願いします

  • provisions の意味を特定できないでいます。

    The regulatory agency regulates prices, standards of service, provisions for safety and other aspects of... provisions の意味が辞書の定義の中から特定できないでいます。「規定」「規約」「規定条項」ほどの意味なのでしょうか、それとも文字通り「準備」とかいった意味なのでしょうか

  • サリエリはモーツァルトを殺したいほど憎しんでいたは

    サリエリはモーツァルトを殺したいほど憎しんでいたは噂話を映画で脚色したもので、実際は両者ともお互いを尊敬しあっていた仲は本当なのだろうか? (サリエリはモーツァルトに招待された魔笛のオペラを大絶賛した記述は有名らしいが) 音楽、歴史カテゴリー皆さんの ご回答のほど、 お待ちしております。 Sarieli died as much as I wanted to kill Mozart was a movie adaptation of the gossip, and indeed the relationship that both of you respected each other is true? (Although Sarieri is famous for describing a great rave reviews of the magical flute opera invited to Mozart) Music, History Category All of you As you answered, We'll be expecting you. https://ja.wikipedia.org/wiki/アントニオ・サリエリ https://en.wikipedia.org/wiki/Antonio_Salieri https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart https://ja.wikipedia.org/wiki/ヴォルフガング・アマデウス・モーツァルト

  • 英文を訳して下さい。

    The German 2nd and 1st armies on the Somme managed a recovery after the string of defeats in September, with fresh divisions to replace exhausted troops and more aircraft, artillery and ammunition diverted from the battle at Verdun and stripped from other parts of the Western Front. Command of the German Air Service (Die Fliegertruppen) was centralised and the new Luftstreitkräfte (German Air Force) was able to challenge Anglo-French air superiority with the reinforcements and new, superior fighter aircraft.

  • 英文翻訳をお願いします。

    The new system was used to calculate losses since August 1914, which took several months but the system had become established by February 1916. The états numériques des pertes were used to calculate casualty figures published in the Journal Officiel, the French Official History and other publications. The German armies compiled Verlustlisten every ten days, which were published by the Reichsarchiv in the deutsches Jahrbuch of 1924–1925. German medical units kept detailed records of medical treatment at the front and in hospital and in 1923, the Zentral Nachweiseamt published an amended edition of the lists produced during the war, incorporating medical service data not in the Verlustlisten. Monthly figures of wounded and ill servicemen that were treated were published in 1934 in the Sanitätsbericht.

  • 1.ニハリとハリームは非常に似通った料理(肉の入っ

    1.ニハリとハリームは非常に似通った料理(肉の入ったシチュー)だがそもそもどのような違いで分けるのだろうか? 2.皆さんはニハリとハリームをどのように見分けられますでしょうか? 3.皆さんにとってニハリ、ハリームとは? 料理カテゴリー皆さんの ご回答のほど、 お待ちしております。 https://ja.m.wikipedia.org/wiki/ニハリ https://es.wikipedia.org/wiki/Nihari https://ja.m.wikipedia.org/wiki/ハリーム https://en.wikipedia.org/wiki/Haleem 1. Nihari and Harim are very similar dishes (meat stew), but what are the differences between them in the first place? 2. How can you distinguish between hari and harim? 3. What's up with you, Harim? Cooking category of everyone As you answer, We'll be expecting you.

  • 障害年金1000人支給停止の利点欠点とは?

    障害年金1000人支給停止の利点欠点とは? なぜ厚生労働省は支給停止を検討しているのだろうか?その意図は公助を減らし、全ての福祉を共助、自助に転換するためなのだろうか? 税金による福祉サービスは政権側の都合で削減されるのは仕方がないことなのか? 障害年金はいつかなくなりやがては民間福祉サービスだけが生き残るのだろうか? 程度の軽い障害年金1000人支給停止を皆さんはどのように思われただろうか? 福祉カテゴリー皆さんの ご回答のほど、 お待ちしております。 https://ja.m.wikipedia.org/wiki/障害年金 https://en.wikipedia.org/wiki/Disability_pension http://www.yomiuri.co.jp/national/20180529-OYT1T50066.html What are the advantages and disadvantages of suspension of 1,000 disability pension pension? Why is the Ministry of Health, Labor and Welfare considering suspension of payment? Is that intention to reduce public aid and convert all welfare to co-help and self-help? Is it impossible to reduce welfare services by tax for the convenience of the administration side? Will disability pension disappear sometime soon will only the private welfare service survive? How seems to you how to stop suspension of 1,000 people with a mild disability pension? Welfare category everyone's As you answered, We'll be expecting you. https://ja.m.wikipedia.org/wiki/ Disability pension https://en.wikipedia.org/wiki/Disability_pension http://www.yomiuri.co.jp/national/20180529-OYT1T50066.html

  • マツコデラックスは需要されるのにlgbtが需要され

    マツコデラックスは需要されるのにlgbtが需要されないのは何故だろうか? マツコデラックスとlgbt は社会ではそれぞれどのように受け止められているのだろうか? 社会カテゴリー皆さんの ご回答のほど、 お待ちしております。 Why is lgbt not required for Matsuko Deluxe to be demanded? How is Matsuko Deluxe and lgbt taken in society respectively? Social Category All of you As you answered, We'll be expecting you. https://ja.m.wikipedia.org/wiki/LGBT https://ja.m.wikipedia.org/wiki/マツコ・デラック

専門家に質問してみよう