diff --git a/_po/ja.po b/_po/ja.po index a53f30e82..111f723f1 100644 --- a/_po/ja.po +++ b/_po/ja.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2019-06-22 19:53+0900\n" +"PO-Revision-Date: 2018-08-11 01:00+0900\n" "Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -3018,7 +3018,7 @@ msgid "## Behaviours" msgstr "" msgid "## Binaries (and bitstrings)" -msgstr "" +msgstr "## バイナリとビット文字列" msgid "## Bitstring generators" msgstr "" @@ -3042,7 +3042,7 @@ msgid "## Calendar improvements" msgstr "" msgid "## Charlists" -msgstr "" +msgstr "## 文字リスト" msgid "## Checking the installed version of Elixir" msgstr "## インストール済み Elixir を確認する" @@ -3644,7 +3644,7 @@ msgid "## Types and specs" msgstr "" msgid "## UTF-8 and Unicode" -msgstr "" +msgstr "## UTF-8 と Unicode" msgid "## UTF-8 atoms, function names and variables" msgstr "" @@ -4596,6 +4596,10 @@ msgid "" "title: Binaries, strings, and charlists\n" "---" msgstr "" +"---\n" +"layout: getting-started\n" +"title: バイナリ、文字列、文字リスト\n" +"---" msgid "" "---\n" @@ -6196,6 +6200,8 @@ msgid "" "t use UTF-8 by default. You can change the encoding of your current session by" " running `chcp 65001` before entering `iex` (`iex.bat`)." msgstr "" +"Note: Windows ではターミナルがデフォルトで UTF-8 が使えないことがあります。`iex` (`iex.bat`)を起動する前に`chcp " +"65001`を実行して現在のセッションのエンコードを変更できます。" msgid "" "> Note: if you want to find and execute a given script in PATH so it will be l" @@ -6375,7 +6381,7 @@ msgstr "" msgid "" "A binary is a sequence of bytes. Those bytes can be organized in any way, even" " in a sequence that does not make them a valid string:" -msgstr "" +msgstr "バイナリとはバイトのシーケンスです。これらのバイトは、どのような方法でも、文字列としては不正なシーケンスにさえ編成され得ます。" msgid "" "A bitstring generator can be mixed with \"regular\" enumerable generators, and s" @@ -6385,12 +6391,12 @@ msgstr "" msgid "" "A charlist is nothing more than a list of code points. Char lists may be creat" "ed with single-quoted literals:" -msgstr "" +msgstr "文字リストとはコードポイントのリストにすぎません。文字リストはシングルクォーテーションを使ったリテラルで作成できます。" msgid "" "A common trick in Elixir is to concatenate the null byte `<<0>>` to a string t" "o see its inner binary representation:" -msgstr "" +msgstr "Elixir では、文字列の内部的なバイナリ表現を確かめる為に空のバイト `<<0>>`` を連結させるというテクニックをよく使います。" msgid "" "A common use case of `:into` can be transforming values in a map, without touc" @@ -6406,6 +6412,11 @@ msgid "" " provides for working with bits and bytes, 99% of the time you will be working" " with binaries and using the `is_binary/1` and `byte_size/1` functions." msgstr "" +"バイナリとビット文字列のコンストラクタに関する詳細な資料は[in the Elixir documentation](https://hexdocs.pm/" +"elixir/Kernel.SpecialForms.html#%3C%3C%3E%3E/1)を参照してください。これにて文字列、バイナリ、ビット文字列のツ" +"アーは終了します。文字列とは UTF-8 でエンコードされたバイナリであり、バイナリとはビット数が 8 で割り切ることのできるビット文字列でした。ここで E" +"lixir がビットとバイトを用いた作業の為の柔軟性が用意されていることを示しましたが、99% はバイナリ操作と `is_binary/1` と `byte" +"_size/1` を使うことになります。" msgid "A comprehension is made of three parts: generators, filters, and collectables." msgstr "" @@ -6495,7 +6506,7 @@ msgstr "" msgid "" "A string is a UTF-8 encoded binary. In order to understand exactly what we mea" "n by that, we need to understand the difference between bytes and code points." -msgstr "" +msgstr "文字列は UTF-8 でエンコードされたバイナリです。この意味を理解する為には、バイトとコードポイントの違いを知る必要があります。" msgid "" "A timeout of 0 can be given when you already expect the message to be in the m" @@ -7894,6 +7905,8 @@ msgid "" "go up to 255. Binaries allow modifiers to be given to store numbers bigger tha" "n 255 or to convert a code point to its UTF-8 representation:" msgstr "" +"バイナリに与えたれている各数字はバイトを表す為であり、255 以下でなければいけません。バイナリは 255 より大きな数字を保持したり、コードポイントを U" +"TF-8 に変換する為に修飾子を受け付けることができます。" msgid "Eager to learn more? Keep reading!" msgstr "もっと知りたいですか?こちらをご覧ください!" @@ -9736,6 +9749,8 @@ msgid "" "ave used the `is_binary/1` function, Elixir must have an underlying type empow" "ering strings. And it does! Let's talk about binaries." msgstr "" +"しかし、文字列型はこの話におけるほんの一部分にでしかありません。文字列がバイナリであり、`is_binary/1`関数を使った時、Elixir には文字列を" +"強化する為に基礎的な型が必要です。というわけで、それをやるとしましょう。今こそバイナリについてお話する時です!" msgid "" "However, the snippet above will spawn and run concurrently as many tasks as th" @@ -9857,7 +9872,7 @@ msgid "" msgstr "" msgid "If a byte has 8 bits, what happens if we pass a size of 1 bit?" -msgstr "" +msgstr "1byte(8bit) に 1bit を渡すとどうなるでしょうか。" msgid "" "If a function with default values has multiple clauses, it is required to crea" @@ -10201,7 +10216,7 @@ msgstr "" msgid "" "In \"Basic types\", we learned about strings and used the `is_binary/1` function" " for checks:" -msgstr "" +msgstr "基本型の章で、我々は文字列について学び、`is_binary/1` 関数を使いました。" msgid "" "In Elixir v0.13, `mix deps.get` only fetches dependencies and it does so accro" @@ -10310,7 +10325,7 @@ msgid "" msgstr "" msgid "In Elixir, you can define a binary using `<<>>`:" -msgstr "" +msgstr "Elixir では `<<>>` を使ってバイナリを定義できます。" msgid "" "In Elixir, your code runs in many processes that talk to each other and the El" @@ -10619,7 +10634,7 @@ msgid "" "ular old libraries that do not accept binaries as arguments. You can convert a" " charlist to a string and back by using the `to_string/1` and `to_charlist/1` " "functions:" -msgstr "" +msgstr "文字リストは、主に Erlang インターフェイスの利用における、特にバイナリを引数として受け付けられないライブラリで使われます。" msgid "" "In practice, however, Elixir developers rarely use the `try/rescue` construct." @@ -11061,6 +11076,8 @@ msgid "" "In this chapter, we will understand what binaries are, how they associate with" " strings, and what a single-quoted value, `'like this'`, means in Elixir." msgstr "" +"Elixir におけるバイナリがどのように文字列と関連するのか、`'こういった単一引用符'` がどういう意味を持っているのか。この章では、バイナリについてそ" +"れが何であるかを理解していきましょう。" msgid "" "In this directory live all assets for `ElixirLangGuide`. The ready to\n" @@ -12153,6 +12170,8 @@ msgid "" "we want to match on a binary of unknown size, it is possible by using the bina" "ry modifier at the end of the pattern:" msgstr "" +"バイナリパターンの各エントリはちょうど 8bit にマッチすることを期待されています。サイズが分からないバイナリでマッチさせたい時には、パターンマッチの最後" +"にバイナリ修飾子を置くことによって可能です。" msgid "" "Note not all tasks have been updated to use strict option parsing. Some tasks," @@ -12260,7 +12279,7 @@ msgstr "" msgid "" "Note that those functions are polymorphic. They not only convert charlists to " "strings, but also integers to strings, atoms to strings, and so on." -msgstr "" +msgstr "これらの関数は多態的に機能します。文字リストを文字列に変換するだけでなく、整数を文字列に変換したり、アトムを文字列に変換することもできます。" msgid "Note that values added to the front are the ones fetched on lookup:" msgstr "" @@ -13375,7 +13394,7 @@ msgid "" msgstr "" msgid "Similar results can be achieved with the string concatenation operator `<>`:" -msgstr "" +msgstr "文字列の連結演算子を使って、類似する結果をアーカイブできます。" msgid "" "Similar to `IEx.pry/0`, once a breakpoint is reached code execution stops unti" @@ -13533,6 +13552,8 @@ msgid "" "en we calculate the `byte_size/1` of a string compared to its `String.length/1" "`:" msgstr "" +"コードポイント `322` が割り振られている `ł` のような文字があるので、実際にはそれを表現する為に 1 バイト以上が必要になります。`String." +"length/1`と`byte_size/1`で比較し、違いを見てみます。" msgid "" "Since we have now changed our registry to use `KV.BucketSupervisor`, which is " @@ -13716,7 +13737,7 @@ msgstr "" msgid "" "String (binary) concatenation uses the `<>` operator but charlists use the lis" "ts concatenation operator `++`:" -msgstr "" +msgstr "文字列 (バイナリ) 連結では `<>` を使いますが、文字リストにはリスト連結の `++` を使います。" msgid "String concatenation is done with `<>`:" msgstr "文字列の連結には `<>` が使われます。" @@ -13996,6 +14017,11 @@ msgid "" "` to `255`. But of course, given you can actually read `\"hełło\"` on your scree" "n, it must be represented *somehow*. That's where encodings come in." msgstr "" +"Unicode は私たちが使う多くの文字にコードポイントを割り振っています。例えば、`a`という文字は`97`のコードポイントを持っていますが、`ł`という" +"文字は`322`のコードポイントを持っています。ディスクに`\"hełło\"`という文字列を書き込む際に、私たちはこれら文字の連なりをバイトに変換しなければな" +"らないのですが、1バイトが一つのコードポイントを表現するというルールに習った場合、`\"hełło\"`を表現することができません。コードポイント`322`は`" +"ł`の為に使用していますが、1バイトでは`0`から`255`の数値を表現することしかできないのです。とはいえ、実際には`\"hełło\"`をスクリーン上で読め" +"るのですから、 *何らかの方法* でそれを表現する必要があります。そこでエンコーディングの出番です。" msgid "" "The [String module](https://hexdocs.pm/elixir/String.html) contains a bunch of" @@ -15236,7 +15262,7 @@ msgstr "" msgid "" "The string concatenation operation is actually a binary concatenation operator" ":" -msgstr "" +msgstr "文字列の連結操作は、実際にはバイナリの連結操作です。" msgid "" "The supervision strategy dictates what happens when one of the children crashe" @@ -15324,7 +15350,7 @@ msgstr "" msgid "" "The value is no longer a binary, but a bitstring -- a bunch of bits! So a bina" "ry is a bitstring where the number of bits is divisible by 8." -msgstr "" +msgstr "値はもはやバイナリではありませんが、ビット文字列、つまりビットの塊です。よって、バイナリはビット数が 8 で割り切ることのできるビット文字列です。" msgid "" "The variable `_` is special in that it can never be read from. Trying to read " @@ -15487,7 +15513,7 @@ msgstr "" msgid "" "There, `byte_size/1` counts the underlying raw bytes, and `String.length/1` co" "unts characters." -msgstr "" +msgstr "ほら。`byte_size/1`は根本的にバイト数を計算しますが、`String.length/1`は文字数を計算していますね。" msgid "" "Therefore, if you don't want to handle the error outcomes, prefer using `File." @@ -16273,6 +16299,8 @@ msgid "" " bytes to represent `ł`. In Elixir, you can get a character's code point by us" "ing `?`:" msgstr "" +"UTF-8 は`h`、`e`、`o`を表現する為にそれぞれ 1 バイトを必要としますが、`ł`の表現には 2 バイトです。Elixir では `?` を使っ" +"て文字のコードポイントを得られます。" msgid "" "Umbrella applications can also be used as a stepping stone for eventually extr" @@ -16565,7 +16593,7 @@ msgid "We can also get the number of bytes in a string:" msgstr "文字列のバイト数も得られます。" msgid "We can also pattern match on binaries / bitstrings:" -msgstr "" +msgstr "バイナリやビット文字列でもパターンマッチができます。" msgid "" "We can also provide our own sigils by implementing functions that follow the `" @@ -17266,6 +17294,9 @@ msgid "" "ng is a UTF-8 encoded binary, we mean a string is a bunch of bytes organized i" "n a way to represent certain code points, as specified by the UTF-8 encoding." msgstr "" +"バイトでコードポイントを表現する際にそれらをどうにかエンコードする必要があります。Elixir はデフォルトのエンコード方式として UTF-8 を採用してい" +"ます。文字列は UTF-8 でエンコードされたバイナリだと述べました。あの意味は、文字列が UTF-8 で指定された通りのコードポイントを表す為に編成される" +"バイトの一塊りだという意味です。" msgid "When running this property, the failure might trigger for a list like this:" msgstr "" @@ -17528,7 +17559,7 @@ msgstr "" msgid "" "With binaries, strings, and charlists out of the way, it is time to talk about" " key-value data structures." -msgstr "" +msgstr "バイナリ、文字列、文字リストについてはこのくらいにして、続いてはキーと値のデータ構造についてお話ししましょう。" msgid "" "With doctests at hand, it is your turn to make tests pass! Once you're ready, " @@ -17777,6 +17808,8 @@ msgid "" "xir/String.html) to split a string in its individual characters, each one as a" " string of length 1:" msgstr "" +"[the `String` module](https://hexdocs.pm/elixir/String.html)の関数を使ってそれぞれを一文字の長さ" +"に分割できます。" msgid "" "You can download and compile Elixir in few steps. The first one is to [install" @@ -17918,6 +17951,9 @@ msgid "" "hile double-quotes represent a string (i.e. a binary), single-quotes represent" " a charlist (i.e. a list)." msgstr "" +"文字リストはバイトの代わりに文字のコードポイントを包含していることが分かりますね (IEx は、いずれかの整数が ASCII の範囲を超える場合のみ、デフォ" +"ルトでコードポイントを出力します)。ダブルクォーテーションが文字列(i.e. バイナリ) を表現するのに対して、シングルクォーテーションは文字リストを表現し" +"ます(i.e. リスト)。" msgid "You can see the new accessors in the `Access` module." msgstr "" @@ -17996,6 +18032,9 @@ msgid "" "ts showcased in the article [\"The string type is broken\"](http://mortoray.com/" "2013/11/27/the-string-type-is-broken/)." msgstr "" +"Elixir が優れた文字列操作をサポートしていることをお分かりいただけると思います。また同時に多くの Unicode 操作もサポートしています。実際、[\"" +"文字列型は壊れている(英語)\"](http://mortoray.com/2013/11/27/the-string-type-is-broken/)という" +"記事で提示されているすべてのテストを Elixir はパスしています。" msgid "" "You'll notice the slightly uncommon terminology of \"outer function\" and\n" diff --git a/_po/ja/getting-started/binaries-strings-and-char-lists.po b/_po/ja/getting-started/binaries-strings-and-char-lists.po index 1cd4b6261..44d8ea374 100644 --- a/_po/ja/getting-started/binaries-strings-and-char-lists.po +++ b/_po/ja/getting-started/binaries-strings-and-char-lists.po @@ -14,6 +14,10 @@ msgid "" "title: Binaries, strings, and charlists\n" "---" msgstr "" +"---\n" +"layout: getting-started\n" +"title: バイナリ、文字列、文字リスト\n" +"---" msgid "# {{ page.title }}" msgstr "" @@ -24,7 +28,7 @@ msgstr "" msgid "" "In \"Basic types\", we learned about strings and used the `is_binary/1` function" " for checks:" -msgstr "" +msgstr "基本型の章で、我々は文字列について学び、`is_binary/1` 関数を使いました。" msgid "" "```iex\n" @@ -39,14 +43,16 @@ msgid "" "In this chapter, we will understand what binaries are, how they associate with" " strings, and what a single-quoted value, `'like this'`, means in Elixir." msgstr "" +"Elixir におけるバイナリがどのように文字列と関連するのか、`'こういった単一引用符'` がどういう意味を持っているのか。この章では、バイナリについてそ" +"れが何であるかを理解していきましょう。" msgid "## UTF-8 and Unicode" -msgstr "" +msgstr "## UTF-8 と Unicode" msgid "" "A string is a UTF-8 encoded binary. In order to understand exactly what we mea" "n by that, we need to understand the difference between bytes and code points." -msgstr "" +msgstr "文字列は UTF-8 でエンコードされたバイナリです。この意味を理解する為には、バイトとコードポイントの違いを知る必要があります。" msgid "" "The Unicode standard assigns code points to many of the characters we know. Fo" @@ -58,6 +64,11 @@ msgid "" "` to `255`. But of course, given you can actually read `\"hełło\"` on your scree" "n, it must be represented *somehow*. That's where encodings come in." msgstr "" +"Unicode は私たちが使う多くの文字にコードポイントを割り振っています。例えば、`a`という文字は`97`のコードポイントを持っていますが、`ł`という" +"文字は`322`のコードポイントを持っています。ディスクに`\"hełło\"`という文字列を書き込む際に、私たちはこれら文字の連なりをバイトに変換しなければな" +"らないのですが、1バイトが一つのコードポイントを表現するというルールに習った場合、`\"hełło\"`を表現することができません。コードポイント`322`は`" +"ł`の為に使用していますが、1バイトでは`0`から`255`の数値を表現することしかできないのです。とはいえ、実際には`\"hełło\"`をスクリーン上で読め" +"るのですから、 *何らかの方法* でそれを表現する必要があります。そこでエンコーディングの出番です。" msgid "" "When representing code points in bytes, we need to encode them somehow. Elixir" @@ -65,6 +76,9 @@ msgid "" "ng is a UTF-8 encoded binary, we mean a string is a bunch of bytes organized i" "n a way to represent certain code points, as specified by the UTF-8 encoding." msgstr "" +"バイトでコードポイントを表現する際にそれらをどうにかエンコードする必要があります。Elixir はデフォルトのエンコード方式として UTF-8 を採用してい" +"ます。文字列は UTF-8 でエンコードされたバイナリだと述べました。あの意味は、文字列が UTF-8 で指定された通りのコードポイントを表す為に編成される" +"バイトの一塊りだという意味です。" msgid "" "Since we have characters like `ł` assigned to the code point `322`, we actuall" @@ -72,6 +86,8 @@ msgid "" "en we calculate the `byte_size/1` of a string compared to its `String.length/1" "`:" msgstr "" +"コードポイント `322` が割り振られている `ł` のような文字があるので、実際にはそれを表現する為に 1 バイト以上が必要になります。`String." +"length/1`と`byte_size/1`で比較し、違いを見てみます。" msgid "" "```iex\n" @@ -87,19 +103,23 @@ msgstr "" msgid "" "There, `byte_size/1` counts the underlying raw bytes, and `String.length/1` co" "unts characters." -msgstr "" +msgstr "ほら。`byte_size/1`は根本的にバイト数を計算しますが、`String.length/1`は文字数を計算していますね。" msgid "" "> Note: if you are running on Windows, there is a chance your terminal does no" "t use UTF-8 by default. You can change the encoding of your current session by" " running `chcp 65001` before entering `iex` (`iex.bat`)." msgstr "" +"Note: Windows ではターミナルがデフォルトで UTF-8 が使えないことがあります。`iex` (`iex.bat`)を起動する前に`chcp " +"65001`を実行して現在のセッションのエンコードを変更できます。" msgid "" "UTF-8 requires one byte to represent the characters `h`, `e`, and `o`, but two" " bytes to represent `ł`. In Elixir, you can get a character's code point by us" "ing `?`:" msgstr "" +"UTF-8 は`h`、`e`、`o`を表現する為にそれぞれ 1 バイトを必要としますが、`ł`の表現には 2 バイトです。Elixir では `?` を使っ" +"て文字のコードポイントを得られます。" msgid "" "```iex\n" @@ -115,6 +135,8 @@ msgid "" "xir/String.html) to split a string in its individual characters, each one as a" " string of length 1:" msgstr "" +"[the `String` module](https://hexdocs.pm/elixir/String.html)の関数を使ってそれぞれを一文字の長さ" +"に分割できます。" msgid "" "```iex\n" @@ -129,18 +151,23 @@ msgid "" "ts showcased in the article [\"The string type is broken\"](http://mortoray.com/" "2013/11/27/the-string-type-is-broken/)." msgstr "" +"Elixir が優れた文字列操作をサポートしていることをお分かりいただけると思います。また同時に多くの Unicode 操作もサポートしています。実際、[\"" +"文字列型は壊れている(英語)\"](http://mortoray.com/2013/11/27/the-string-type-is-broken/)という" +"記事で提示されているすべてのテストを Elixir はパスしています。" msgid "" "However, strings are just part of the story. If a string is a binary, and we h" "ave used the `is_binary/1` function, Elixir must have an underlying type empow" "ering strings. And it does! Let's talk about binaries." msgstr "" +"しかし、文字列型はこの話におけるほんの一部分にでしかありません。文字列がバイナリであり、`is_binary/1`関数を使った時、Elixir には文字列を" +"強化する為に基礎的な型が必要です。というわけで、それをやるとしましょう。今こそバイナリについてお話する時です!" msgid "## Binaries (and bitstrings)" -msgstr "" +msgstr "## バイナリとビット文字列" msgid "In Elixir, you can define a binary using `<<>>`:" -msgstr "" +msgstr "Elixir では `<<>>` を使ってバイナリを定義できます。" msgid "" "```iex\n" @@ -154,7 +181,7 @@ msgstr "" msgid "" "A binary is a sequence of bytes. Those bytes can be organized in any way, even" " in a sequence that does not make them a valid string:" -msgstr "" +msgstr "バイナリとはバイトのシーケンスです。これらのバイトは、どのような方法でも、文字列としては不正なシーケンスにさえ編成され得ます。" msgid "" "```iex\n" @@ -166,7 +193,7 @@ msgstr "" msgid "" "The string concatenation operation is actually a binary concatenation operator" ":" -msgstr "" +msgstr "文字列の連結操作は、実際にはバイナリの連結操作です。" msgid "" "```iex\n" @@ -178,7 +205,7 @@ msgstr "" msgid "" "A common trick in Elixir is to concatenate the null byte `<<0>>` to a string t" "o see its inner binary representation:" -msgstr "" +msgstr "Elixir では、文字列の内部的なバイナリ表現を確かめる為に空のバイト `<<0>>`` を連結させるというテクニックをよく使います。" msgid "" "```iex\n" @@ -192,6 +219,8 @@ msgid "" "go up to 255. Binaries allow modifiers to be given to store numbers bigger tha" "n 255 or to convert a code point to its UTF-8 representation:" msgstr "" +"バイナリに与えたれている各数字はバイトを表す為であり、255 以下でなければいけません。バイナリは 255 より大きな数字を保持したり、コードポイントを U" +"TF-8 に変換する為に修飾子を受け付けることができます。" msgid "" "```iex\n" @@ -209,7 +238,7 @@ msgid "" msgstr "" msgid "If a byte has 8 bits, what happens if we pass a size of 1 bit?" -msgstr "" +msgstr "1byte(8bit) に 1bit を渡すとどうなるでしょうか。" msgid "" "```iex\n" @@ -229,7 +258,7 @@ msgstr "" msgid "" "The value is no longer a binary, but a bitstring -- a bunch of bits! So a bina" "ry is a bitstring where the number of bits is divisible by 8." -msgstr "" +msgstr "値はもはやバイナリではありませんが、ビット文字列、つまりビットの塊です。よって、バイナリはビット数が 8 で割り切ることのできるビット文字列です。" msgid "" "```iex\n" @@ -241,7 +270,7 @@ msgid "" msgstr "" msgid "We can also pattern match on binaries / bitstrings:" -msgstr "" +msgstr "バイナリやビット文字列でもパターンマッチができます。" msgid "" "```iex\n" @@ -259,6 +288,8 @@ msgid "" "we want to match on a binary of unknown size, it is possible by using the bina" "ry modifier at the end of the pattern:" msgstr "" +"バイナリパターンの各エントリはちょうど 8bit にマッチすることを期待されています。サイズが分からないバイナリでマッチさせたい時には、パターンマッチの最後" +"にバイナリ修飾子を置くことによって可能です。" msgid "" "```iex\n" @@ -270,7 +301,7 @@ msgid "" msgstr "" msgid "Similar results can be achieved with the string concatenation operator `<>`:" -msgstr "" +msgstr "文字列の連結演算子を使って、類似する結果を得ることができます。" msgid "" "```iex\n" @@ -290,14 +321,19 @@ msgid "" " provides for working with bits and bytes, 99% of the time you will be working" " with binaries and using the `is_binary/1` and `byte_size/1` functions." msgstr "" +"バイナリとビット文字列のコンストラクタに関する詳細な資料は[in the Elixir documentation](https://hexdocs.pm/" +"elixir/Kernel.SpecialForms.html#%3C%3C%3E%3E/1)を参照してください。これにて文字列、バイナリ、ビット文字列のツ" +"アーは終了します。文字列とは UTF-8 でエンコードされたバイナリであり、バイナリとはビット数が 8 で割り切ることのできるビット文字列でした。ここで E" +"lixir がビットとバイトを用いた作業の為の柔軟性が用意されていることを示しましたが、99% はバイナリ操作と `is_binary/1` と `byte" +"_size/1` を使うことになります。" msgid "## Charlists" -msgstr "" +msgstr "## 文字リスト" msgid "" "A charlist is nothing more than a list of code points. Char lists may be creat" "ed with single-quoted literals:" -msgstr "" +msgstr "文字リストとはコードポイントのリストにすぎません。文字リストはシングルクォーテーションを使ったリテラルで作成できます。" msgid "" "```iex\n" @@ -319,13 +355,16 @@ msgid "" "hile double-quotes represent a string (i.e. a binary), single-quotes represent" " a charlist (i.e. a list)." msgstr "" +"文字リストはバイトの代わりに文字のコードポイントを包含していることが分かりますね (IEx は、いずれかの整数が ASCII の範囲を超える場合のみ、デフォ" +"ルトでコードポイントを出力します)。ダブルクォーテーションが文字列(i.e. バイナリ) を表現するのに対して、シングルクォーテーションは文字リストを表現し" +"ます(i.e. リスト)。" msgid "" "In practice, charlists are used mostly when interfacing with Erlang, in partic" "ular old libraries that do not accept binaries as arguments. You can convert a" " charlist to a string and back by using the `to_string/1` and `to_charlist/1` " "functions:" -msgstr "" +msgstr 実際には、文字リストは特に引数としてバイナリを受け付けない古いErlangライブラリとの、インターフェイスとして使われます。 `to_string/1` や `to_charlist/1` 関数を使って、文字リストを文字列に変換したり、文字列から文字リストに変換したりできます。 msgid "" "```iex\n" @@ -343,12 +382,12 @@ msgstr "" msgid "" "Note that those functions are polymorphic. They not only convert charlists to " "strings, but also integers to strings, atoms to strings, and so on." -msgstr "" +msgstr "これらの関数は多態的に機能します。文字リストを文字列に変換するだけでなく、整数を文字列に変換したり、アトムを文字列に変換することもできます。" msgid "" "String (binary) concatenation uses the `<>` operator but charlists use the lis" "ts concatenation operator `++`:" -msgstr "" +msgstr "文字列 (バイナリ) 連結では `<>` を使いますが、文字リストにはリスト連結の `++` を使います。" msgid "" "```iex\n" @@ -371,4 +410,4 @@ msgstr "" msgid "" "With binaries, strings, and charlists out of the way, it is time to talk about" " key-value data structures." -msgstr "" +msgstr "バイナリ、文字列、文字リストについてはこのくらいにして、続いてはキーと値のデータ構造についてお話ししましょう。" diff --git a/_po/ja/getting-started/binaries-strings-and-char-lists.pot b/_po/ja/getting-started/binaries-strings-and-char-lists.pot index 0738e0a2c..de10659ad 100644 --- a/_po/ja/getting-started/binaries-strings-and-char-lists.pot +++ b/_po/ja/getting-started/binaries-strings-and-char-lists.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 23:39+0900\n" +"POT-Creation-Date: 2019-10-24 13:01+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/docs/getting-started/binaries-strings-and-char-lists.html b/docs/getting-started/binaries-strings-and-char-lists.html index c819d5951..2cfd80fd8 100644 --- a/docs/getting-started/binaries-strings-and-char-lists.html +++ b/docs/getting-started/binaries-strings-and-char-lists.html @@ -3,7 +3,7 @@ - Binaries, strings, and charlists - Elixir + バイナリ、文字列、文字リスト - Elixir @@ -24,12 +24,12 @@ gtag('config', 'UA-8268430-6'); - + +{"@context":"http://schema.org","@type":"WebPage","headline":"バイナリ、文字列、文字リスト","url":"https://elixir-lang.org/ja/getting-started/binaries-strings-and-char-lists.html"} @@ -220,11 +220,11 @@

Created at

-

Binaries, strings, and charlists

+

バイナリ、文字列、文字リスト

-

In “Basic types”, we learned about strings and used the is_binary/1 function for checks:

+

基本型の章で、我々は文字列について学び、is_binary/1 関数を使いました。

iex> string = "hello"
 "hello"
@@ -232,17 +232,17 @@ 

Binaries, strings, and charlists

true
-

In this chapter, we will understand what binaries are, how they associate with strings, and what a single-quoted value, 'like this', means in Elixir.

+

Elixir におけるバイナリがどのように文字列と関連するのか、'こういった単一引用符' がどういう意味を持っているのか。この章では、バイナリについてそれが何であるかを理解していきましょう。

-

UTF-8 and Unicode

+

UTF-8 と Unicode

-

A string is a UTF-8 encoded binary. In order to understand exactly what we mean by that, we need to understand the difference between bytes and code points.

+

文字列は UTF-8 でエンコードされたバイナリです。この意味を理解する為には、バイトとコードポイントの違いを知る必要があります。

-

The Unicode standard assigns code points to many of the characters we know. For example, the letter a has code point 97 while the letter ł has code point 322. When writing the string "hełło" to disk, we need to convert this sequence of characters to bytes. If we adopted a rule that said one byte represents one code point, we wouldn’t be able to write "hełło", because it uses the code point 322 for ł, and one byte can only represent a number from 0 to 255. But of course, given you can actually read "hełło" on your screen, it must be represented somehow. That’s where encodings come in.

+

Unicode は私たちが使う多くの文字にコードポイントを割り振っています。例えば、aという文字は97のコードポイントを持っていますが、łという文字は322のコードポイントを持っています。ディスクに"hełło"という文字列を書き込む際に、私たちはこれら文字の連なりをバイトに変換しなければならないのですが、1バイトが一つのコードポイントを表現するというルールに習った場合、"hełło"を表現することができません。コードポイント322łの為に使用していますが、1バイトでは0から255の数値を表現することしかできないのです。とはいえ、実際には”`“hełło\

-

When representing code points in bytes, we need to encode them somehow. Elixir chose the UTF-8 encoding as its main and default encoding. When we say a string is a UTF-8 encoded binary, we mean a string is a bunch of bytes organized in a way to represent certain code points, as specified by the UTF-8 encoding.

+

バイトでコードポイントを表現する際にそれらをどうにかエンコードする必要があります。Elixir はデフォルトのエンコード方式として UTF-8 を採用しています。文字列は UTF-8 でエンコードされたバイナリだと述べました。あの意味は、文字列が UTF-8 で指定された通りのコードポイントを表す為に編成されるバイトの一塊りだという意味です。

-

Since we have characters like ł assigned to the code point 322, we actually need more than one byte to represent them. That’s why we see a difference when we calculate the byte_size/1 of a string compared to its String.length/1:

+

コードポイント 322 が割り振られている ł のような文字があるので、実際にはそれを表現する為に 1 バイト以上が必要になります。String.length/1byte_size/1で比較し、違いを見てみます。

iex> string = "hełło"
 "hełło"
@@ -252,13 +252,11 @@ 

UTF-8 and Unicode

5
-

There, byte_size/1 counts the underlying raw bytes, and String.length/1 counts characters.

+

ほら。byte_size/1は根本的にバイト数を計算しますが、String.length/1は文字数を計算していますね。

-
-

Note: if you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running chcp 65001 before entering iex (iex.bat).

-
+

Note: Windows ではターミナルがデフォルトで UTF-8 が使えないことがあります。iex (iex.bat)を起動する前にchcp 65001を実行して現在のセッションのエンコードを変更できます。

-

UTF-8 requires one byte to represent the characters h, e, and o, but two bytes to represent ł. In Elixir, you can get a character’s code point by using ?:

+

UTF-8 はheoを表現する為にそれぞれ 1 バイトを必要としますが、łの表現には 2 バイトです。Elixir では ? を使って文字のコードポイントを得られます。

iex> ?a
 97
@@ -266,19 +264,19 @@ 

UTF-8 and Unicode

322
-

You can also use the functions in the String module to split a string in its individual characters, each one as a string of length 1:

+

the String moduleの関数を使ってそれぞれを一文字の長さに分割できます。

iex> String.codepoints("hełło")
 ["h", "e", "ł", "ł", "o"]
 
-

You will see that Elixir has excellent support for working with strings. It also supports many of the Unicode operations. In fact, Elixir passes all the tests showcased in the article “The string type is broken”.

+

Elixir が優れた文字列操作をサポートしていることをお分かりいただけると思います。また同時に多くの Unicode 操作もサポートしています。実際、“文字列型は壊れている(英語)”という記事で提示されているすべてのテストを Elixir はパスしています。

-

However, strings are just part of the story. If a string is a binary, and we have used the is_binary/1 function, Elixir must have an underlying type empowering strings. And it does! Let’s talk about binaries.

+

しかし、文字列型はこの話におけるほんの一部分にでしかありません。文字列がバイナリであり、is_binary/1関数を使った時、Elixir には文字列を強化する為に基礎的な型が必要です。というわけで、それをやるとしましょう。今こそバイナリについてお話する時です!

-

Binaries (and bitstrings)

+

バイナリとビット文字列

-

In Elixir, you can define a binary using <<>>:

+

Elixir では <<>> を使ってバイナリを定義できます。

iex> <<0, 1, 2, 3>>
 <<0, 1, 2, 3>>
@@ -286,25 +284,25 @@ 

Binaries (and bitstrings)

4
-

A binary is a sequence of bytes. Those bytes can be organized in any way, even in a sequence that does not make them a valid string:

+

バイナリとはバイトのシーケンスです。これらのバイトは、どのような方法でも、文字列としては不正なシーケンスにさえ編成され得ます。

iex> String.valid?(<<239, 191, 19>>)
 false
 
-

The string concatenation operation is actually a binary concatenation operator:

+

文字列の連結操作は、実際にはバイナリの連結操作です。

iex> <<0, 1>> <> <<2, 3>>
 <<0, 1, 2, 3>>
 
-

A common trick in Elixir is to concatenate the null byte <<0>> to a string to see its inner binary representation:

+

Elixir では、文字列の内部的なバイナリ表現を確かめる為に空のバイト <<0>>` を連結させるというテクニックをよく使います。

iex> "hełło" <> <<0>>
 <<104, 101, 197, 130, 197, 130, 111, 0>>
 
-

Each number given to a binary is meant to represent a byte and therefore must go up to 255. Binaries allow modifiers to be given to store numbers bigger than 255 or to convert a code point to its UTF-8 representation:

+

バイナリに与えたれている各数字はバイトを表す為であり、255 以下でなければいけません。バイナリは 255 より大きな数字を保持したり、コードポイントを UTF-8 に変換する為に修飾子を受け付けることができます。

iex> <<255>>
 <<255>>
@@ -318,7 +316,7 @@ 

Binaries (and bitstrings)

<<196, 128, 0>>
-

If a byte has 8 bits, what happens if we pass a size of 1 bit?

+

1byte(8bit) に 1bit を渡すとどうなるでしょうか。

iex> <<1 :: size(1)>>
 <<1::size(1)>>
@@ -332,7 +330,7 @@ 

Binaries (and bitstrings)

1
-

The value is no longer a binary, but a bitstring – a bunch of bits! So a binary is a bitstring where the number of bits is divisible by 8.

+

値はもはやバイナリではありませんが、ビット文字列、つまりビットの塊です。よって、バイナリはビット数が 8 で割り切ることのできるビット文字列です。

iex>  is_binary(<<1 :: size(16)>>)
 true
@@ -340,7 +338,7 @@ 

Binaries (and bitstrings)

false
-

We can also pattern match on binaries / bitstrings:

+

バイナリやビット文字列でもパターンマッチができます。

iex> <<0, 1, x>> = <<0, 1, 2>>
 <<0, 1, 2>>
@@ -350,7 +348,7 @@ 

Binaries (and bitstrings)

** (MatchError) no match of right hand side value: <<0, 1, 2, 3>>
-

Note each entry in the binary pattern is expected to match exactly 8 bits. If we want to match on a binary of unknown size, it is possible by using the binary modifier at the end of the pattern:

+

バイナリパターンの各エントリはちょうど 8bit にマッチすることを期待されています。サイズが分からないバイナリでマッチさせたい時には、パターンマッチの最後にバイナリ修飾子を置くことによって可能です。

iex> <<0, 1, x :: binary>> = <<0, 1, 2, 3>>
 <<0, 1, 2, 3>>
@@ -358,7 +356,7 @@ 

Binaries (and bitstrings)

<<2, 3>>
-

Similar results can be achieved with the string concatenation operator <>:

+

文字列の連結演算子を使って、類似する結果をアーカイブできます。

iex> "he" <> rest = "hello"
 "hello"
@@ -366,11 +364,11 @@ 

Binaries (and bitstrings)

"llo"
-

A complete reference about the binary / bitstring constructor <<>> can be found in the Elixir documentation. This concludes our tour of bitstrings, binaries and strings. A string is a UTF-8 encoded binary and a binary is a bitstring where the number of bits is divisible by 8. Although this shows the flexibility Elixir provides for working with bits and bytes, 99% of the time you will be working with binaries and using the is_binary/1 and byte_size/1 functions.

+

バイナリとビット文字列のコンストラクタに関する詳細な資料はin the Elixir documentationを参照してください。これにて文字列、バイナリ、ビット文字列のツアーは終了します。文字列とは UTF-8 でエンコードされたバイナリであり、バイナリとはビット数が 8 で割り切ることのできるビット文字列でした。ここで Elixir がビットとバイトを用いた作業の為の柔軟性が用意されていることを示しましたが、99% はバイナリ操作と is_binary/1byte_size/1 を使うことになります。

-

Charlists

+

文字リスト

-

A charlist is nothing more than a list of code points. Char lists may be created with single-quoted literals:

+

文字リストとはコードポイントのリストにすぎません。文字リストはシングルクォーテーションを使ったリテラルで作成できます。

iex> 'hełło'
 [104, 101, 322, 322, 111]
@@ -382,9 +380,9 @@ 

Charlists

104
-

You can see that, instead of containing bytes, a charlist contains the code points of the characters between single-quotes (note that by default IEx will only output code points if any of the integers is outside the ASCII range). So while double-quotes represent a string (i.e. a binary), single-quotes represent a charlist (i.e. a list).

+

文字リストはバイトの代わりに文字のコードポイントを包含していることが分かりますね (IEx は、いずれかの整数が ASCII の範囲を超える場合のみ、デフォルトでコードポイントを出力します)。ダブルクォーテーションが文字列(i.e. バイナリ) を表現するのに対して、シングルクォーテーションは文字リストを表現します(i.e. リスト)。

-

In practice, charlists are used mostly when interfacing with Erlang, in particular old libraries that do not accept binaries as arguments. You can convert a charlist to a string and back by using the to_string/1 and to_charlist/1 functions:

+

文字リストは、主に Erlang インターフェイスの利用における、特にバイナリを引数として受け付けられないライブラリで使われます。

iex> to_charlist "hełło"
 [104, 101, 322, 322, 111]
@@ -396,9 +394,9 @@ 

Charlists

"1"
-

Note that those functions are polymorphic. They not only convert charlists to strings, but also integers to strings, atoms to strings, and so on.

+

これらの関数は多態的に機能します。文字リストを文字列に変換するだけでなく、整数を文字列に変換したり、アトムを文字列に変換することもできます。

-

String (binary) concatenation uses the <> operator but charlists use the lists concatenation operator ++:

+

文字列 (バイナリ) 連結では <> を使いますが、文字リストにはリスト連結の ++ を使います。

iex> 'this ' <> 'fails'
 ** (CompileError) iex:2: invalid literal 'this ' in <<>>
@@ -415,7 +413,7 @@ 

Charlists

"hello"
-

With binaries, strings, and charlists out of the way, it is time to talk about key-value data structures.

+

バイナリ、文字列、文字リストについてはこのくらいにして、続いてはキーと値のデータ構造についてお話ししましょう。

diff --git a/ja/getting-started/binaries-strings-and-char-lists.markdown b/ja/getting-started/binaries-strings-and-char-lists.markdown index eeda78c98..d51c95cdc 100644 --- a/ja/getting-started/binaries-strings-and-char-lists.markdown +++ b/ja/getting-started/binaries-strings-and-char-lists.markdown @@ -1,13 +1,13 @@ --- layout: getting-started -title: Binaries, strings, and charlists +title: バイナリ、文字列、文字リスト --- # {{ page.title }} {% include toc.html %} -In "Basic types", we learned about strings and used the `is_binary/1` function for checks: +基本型の章で、我々は文字列について学び、`is_binary/1` 関数を使いました。 ```iex iex> string = "hello" @@ -16,17 +16,17 @@ iex> is_binary(string) true ``` -In this chapter, we will understand what binaries are, how they associate with strings, and what a single-quoted value, `'like this'`, means in Elixir. +Elixir におけるバイナリがどのように文字列と関連するのか、`'こういった単一引用符'` がどういう意味を持っているのか。この章では、バイナリについてそれが何であるかを理解していきましょう。 -## UTF-8 and Unicode +## UTF-8 と Unicode -A string is a UTF-8 encoded binary. In order to understand exactly what we mean by that, we need to understand the difference between bytes and code points. +文字列は UTF-8 でエンコードされたバイナリです。この意味を理解する為には、バイトとコードポイントの違いを知る必要があります。 -The Unicode standard assigns code points to many of the characters we know. For example, the letter `a` has code point `97` while the letter `ł` has code point `322`. When writing the string `"hełło"` to disk, we need to convert this sequence of characters to bytes. If we adopted a rule that said one byte represents one code point, we wouldn't be able to write `"hełło"`, because it uses the code point `322` for `ł`, and one byte can only represent a number from `0` to `255`. But of course, given you can actually read `"hełło"` on your screen, it must be represented *somehow*. That's where encodings come in. +Unicode は私たちが使う多くの文字にコードポイントを割り振っています。例えば、`a`という文字は`97`のコードポイントを持っていますが、`ł`という文字は`322`のコードポイントを持っています。ディスクに`"hełło"`という文字列を書き込む際に、私たちはこれら文字の連なりをバイトに変換しなければならないのですが、1バイトが一つのコードポイントを表現するというルールに習った場合、`"hełło"`を表現することができません。コードポイント`322`は`ł`の為に使用していますが、1バイトでは`0`から`255`の数値を表現することしかできないのです。とはいえ、実際には`"hełło"`をスクリーン上で読めるのですから、 *何らかの方法* でそれを表現する必要があります。そこでエンコーディングの出番です。 -When representing code points in bytes, we need to encode them somehow. Elixir chose the UTF-8 encoding as its main and default encoding. When we say a string is a UTF-8 encoded binary, we mean a string is a bunch of bytes organized in a way to represent certain code points, as specified by the UTF-8 encoding. +バイトでコードポイントを表現する際にそれらをどうにかエンコードする必要があります。Elixir はデフォルトのエンコード方式として UTF-8 を採用しています。文字列は UTF-8 でエンコードされたバイナリだと述べました。あの意味は、文字列が UTF-8 で指定された通りのコードポイントを表す為に編成されるバイトの一塊りだという意味です。 -Since we have characters like `ł` assigned to the code point `322`, we actually need more than one byte to represent them. That's why we see a difference when we calculate the `byte_size/1` of a string compared to its `String.length/1`: +コードポイント `322` が割り振られている `ł` のような文字があるので、実際にはそれを表現する為に 1 バイト以上が必要になります。`String.length/1`と`byte_size/1`で比較し、違いを見てみます。 ```iex iex> string = "hełło" @@ -37,11 +37,11 @@ iex> String.length(string) 5 ``` -There, `byte_size/1` counts the underlying raw bytes, and `String.length/1` counts characters. +ほら。`byte_size/1`は根本的にバイト数を計算しますが、`String.length/1`は文字数を計算していますね。 -> Note: if you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running `chcp 65001` before entering `iex` (`iex.bat`). +Note: Windows ではターミナルがデフォルトで UTF-8 が使えないことがあります。`iex` (`iex.bat`)を起動する前に`chcp 65001`を実行して現在のセッションのエンコードを変更できます。 -UTF-8 requires one byte to represent the characters `h`, `e`, and `o`, but two bytes to represent `ł`. In Elixir, you can get a character's code point by using `?`: +UTF-8 は`h`、`e`、`o`を表現する為にそれぞれ 1 バイトを必要としますが、`ł`の表現には 2 バイトです。Elixir では `?` を使って文字のコードポイントを得られます。 ```iex iex> ?a @@ -50,20 +50,20 @@ iex> ?ł 322 ``` -You can also use the functions in [the `String` module](https://hexdocs.pm/elixir/String.html) to split a string in its individual characters, each one as a string of length 1: +[the `String` module](https://hexdocs.pm/elixir/String.html)の関数を使ってそれぞれを一文字の長さに分割できます。 ```iex iex> String.codepoints("hełło") ["h", "e", "ł", "ł", "o"] ``` -You will see that Elixir has excellent support for working with strings. It also supports many of the Unicode operations. In fact, Elixir passes all the tests showcased in the article ["The string type is broken"](http://mortoray.com/2013/11/27/the-string-type-is-broken/). +Elixir が優れた文字列操作をサポートしていることをお分かりいただけると思います。また同時に多くの Unicode 操作もサポートしています。実際、["文字列型は壊れている(英語)"](http://mortoray.com/2013/11/27/the-string-type-is-broken/)という記事で提示されているすべてのテストを Elixir はパスしています。 -However, strings are just part of the story. If a string is a binary, and we have used the `is_binary/1` function, Elixir must have an underlying type empowering strings. And it does! Let's talk about binaries. +しかし、文字列型はこの話におけるほんの一部分にでしかありません。文字列がバイナリであり、`is_binary/1`関数を使った時、Elixir には文字列を強化する為に基礎的な型が必要です。というわけで、それをやるとしましょう。今こそバイナリについてお話する時です! -## Binaries (and bitstrings) +## バイナリとビット文字列 -In Elixir, you can define a binary using `<<>>`: +Elixir では `<<>>` を使ってバイナリを定義できます。 ```iex iex> <<0, 1, 2, 3>> @@ -72,28 +72,28 @@ iex> byte_size(<<0, 1, 2, 3>>) 4 ``` -A binary is a sequence of bytes. Those bytes can be organized in any way, even in a sequence that does not make them a valid string: +バイナリとはバイトのシーケンスです。これらのバイトは、どのような方法でも、文字列としては不正なシーケンスにさえ編成され得ます。 ```iex iex> String.valid?(<<239, 191, 19>>) false ``` -The string concatenation operation is actually a binary concatenation operator: +文字列の連結操作は、実際にはバイナリの連結操作です。 ```iex iex> <<0, 1>> <> <<2, 3>> <<0, 1, 2, 3>> ``` -A common trick in Elixir is to concatenate the null byte `<<0>>` to a string to see its inner binary representation: +Elixir では、文字列の内部的なバイナリ表現を確かめる為に空のバイト `<<0>>`` を連結させるというテクニックをよく使います。 ```iex iex> "hełło" <> <<0>> <<104, 101, 197, 130, 197, 130, 111, 0>> ``` -Each number given to a binary is meant to represent a byte and therefore must go up to 255. Binaries allow modifiers to be given to store numbers bigger than 255 or to convert a code point to its UTF-8 representation: +バイナリに与えたれている各数字はバイトを表す為であり、255 以下でなければいけません。バイナリは 255 より大きな数字を保持したり、コードポイントを UTF-8 に変換する為に修飾子を受け付けることができます。 ```iex iex> <<255>> @@ -108,7 +108,7 @@ iex> <<256 :: utf8, 0>> <<196, 128, 0>> ``` -If a byte has 8 bits, what happens if we pass a size of 1 bit? +1byte(8bit) に 1bit を渡すとどうなるでしょうか。 ```iex iex> <<1 :: size(1)>> @@ -123,7 +123,7 @@ iex> bit_size(<<1 :: size(1)>>) 1 ``` -The value is no longer a binary, but a bitstring -- a bunch of bits! So a binary is a bitstring where the number of bits is divisible by 8. +値はもはやバイナリではありませんが、ビット文字列、つまりビットの塊です。よって、バイナリはビット数が 8 で割り切ることのできるビット文字列です。 ```iex iex> is_binary(<<1 :: size(16)>>) @@ -132,7 +132,7 @@ iex> is_binary(<<1 :: size(15)>>) false ``` -We can also pattern match on binaries / bitstrings: +バイナリやビット文字列でもパターンマッチができます。 ```iex iex> <<0, 1, x>> = <<0, 1, 2>> @@ -143,7 +143,7 @@ iex> <<0, 1, x>> = <<0, 1, 2, 3>> ** (MatchError) no match of right hand side value: <<0, 1, 2, 3>> ``` -Note each entry in the binary pattern is expected to match exactly 8 bits. If we want to match on a binary of unknown size, it is possible by using the binary modifier at the end of the pattern: +バイナリパターンの各エントリはちょうど 8bit にマッチすることを期待されています。サイズが分からないバイナリでマッチさせたい時には、パターンマッチの最後にバイナリ修飾子を置くことによって可能です。 ```iex iex> <<0, 1, x :: binary>> = <<0, 1, 2, 3>> @@ -152,7 +152,7 @@ iex> x <<2, 3>> ``` -Similar results can be achieved with the string concatenation operator `<>`: +文字列の連結演算子を使って、類似する結果をアーカイブできます。 ```iex iex> "he" <> rest = "hello" @@ -161,11 +161,11 @@ iex> rest "llo" ``` -A complete reference about the binary / bitstring constructor `<<>>` can be found [in the Elixir documentation](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%3C%3C%3E%3E/1). This concludes our tour of bitstrings, binaries and strings. A string is a UTF-8 encoded binary and a binary is a bitstring where the number of bits is divisible by 8. Although this shows the flexibility Elixir provides for working with bits and bytes, 99% of the time you will be working with binaries and using the `is_binary/1` and `byte_size/1` functions. +バイナリとビット文字列のコンストラクタに関する詳細な資料は[in the Elixir documentation](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%3C%3C%3E%3E/1)を参照してください。これにて文字列、バイナリ、ビット文字列のツアーは終了します。文字列とは UTF-8 でエンコードされたバイナリであり、バイナリとはビット数が 8 で割り切ることのできるビット文字列でした。ここで Elixir がビットとバイトを用いた作業の為の柔軟性が用意されていることを示しましたが、99% はバイナリ操作と `is_binary/1` と `byte_size/1` を使うことになります。 -## Charlists +## 文字リスト -A charlist is nothing more than a list of code points. Char lists may be created with single-quoted literals: +文字リストとはコードポイントのリストにすぎません。文字リストはシングルクォーテーションを使ったリテラルで作成できます。 ```iex iex> 'hełło' @@ -178,9 +178,9 @@ iex> List.first('hello') 104 ``` -You can see that, instead of containing bytes, a charlist contains the code points of the characters between single-quotes (note that by default IEx will only output code points if any of the integers is outside the ASCII range). So while double-quotes represent a string (i.e. a binary), single-quotes represent a charlist (i.e. a list). +文字リストはバイトの代わりに文字のコードポイントを包含していることが分かりますね (IEx は、いずれかの整数が ASCII の範囲を超える場合のみ、デフォルトでコードポイントを出力します)。ダブルクォーテーションが文字列(i.e. バイナリ) を表現するのに対して、シングルクォーテーションは文字リストを表現します(i.e. リスト)。 -In practice, charlists are used mostly when interfacing with Erlang, in particular old libraries that do not accept binaries as arguments. You can convert a charlist to a string and back by using the `to_string/1` and `to_charlist/1` functions: +文字リストは、主に Erlang インターフェイスの利用における、特にバイナリを引数として受け付けられないライブラリで使われます。 ```iex iex> to_charlist "hełło" @@ -193,9 +193,9 @@ iex> to_string 1 "1" ``` -Note that those functions are polymorphic. They not only convert charlists to strings, but also integers to strings, atoms to strings, and so on. +これらの関数は多態的に機能します。文字リストを文字列に変換するだけでなく、整数を文字列に変換したり、アトムを文字列に変換することもできます。 -String (binary) concatenation uses the `<>` operator but charlists use the lists concatenation operator `++`: +文字列 (バイナリ) 連結では `<>` を使いますが、文字リストにはリスト連結の `++` を使います。 ```iex iex> 'this ' <> 'fails' @@ -213,4 +213,4 @@ iex> "he" <> "llo" "hello" ``` -With binaries, strings, and charlists out of the way, it is time to talk about key-value data structures. +バイナリ、文字列、文字リストについてはこのくらいにして、続いてはキーと値のデータ構造についてお話ししましょう。