{"action":"created","comment":{"url":"https://api.github.com/repos/hoaproject/String/pulls/comments/22757651","id":22757651,"diff_hunk":"@@ -3,8 +3,608 @@\n <overlay xmlns=\"http://hoa-project.net/xyl/xylophone\">\n <yield id=\"chapter\">\n \n-  <p class=\"warning\">This chapter is not yet translated. Contributions are\n-  welcomed!</p>\n+  <p>Strings can sometimes be <strong>complex</strong>, especially when they use\n+  the <code>Unicode</code> encoding format. The <code>Hoa\\String</code> library\n+  provides several operations on UTF-8 strings.</p>\n+\n+  <h2 id=\"Table_of_contents\">Table of contents</h2>\n+\n+  <tableofcontents id=\"main-toc\" />\n+\n+  <h2 id=\"Introduction\" for=\"main-toc\">Introduction</h2>\n+\n+  <p>When we manipulate strings, the <a href=\"http://unicode.org/\">Unicode</a>\n+  format establishes itself because of its <strong>compatibility</strong> with\n+  historical formats (like ASCII) and its capacity to understand a\n+  <strong>large</strong> range of characters and symbols for all cultures and\n+  all regions in the world. PHP provides several tools to manipulate such\n+  strings, like the following extensions:\n+  <a href=\"http://php.net/mbstring\"><code>mbstring</code></a>,\n+  <a href=\"http://php.net/iconv\"><code>iconv</code></a> or also the excellent\n+  <a href=\"http://php.net/intl\"><code>intl</code></a>  which is based on\n+  <a href=\"http://icu-project.org/\">ICU</a>, the reference implementation of\n+  Unicode. Unfortunately, sometimes we have to mix these extensions to achieve\n+  our aims and at the cost of a certain <strong>complexity</strong> along with\n+  a regrettable <strong>verbosity</strong>.</p>\n+  <p>The <code>Hoa\\String</code> library answers to these issues by providing a\n+  <strong>simple</strong> way to manipulate strings with\n+  <strong>performance</strong> and <strong>efficiency</strong> in minds. It\n+  also provides some evoluated algorithms to perform <strong>search</strong>\n+  operations on strings.</p>\n+\n+  <h2 id=\"Unicode_strings\" for=\"main-toc\">Unicode strings</h2>\n+\n+  <p>The <code>Hoa\\String\\String</code> class represents a\n+  <strong>UTF-8</strong> Unicode strings and allows to manipulate it easily.\n+  This class implements the\n+  <a href=\"http://php.net/arrayaccess\"><code>ArrayAccess</code></a>,\n+  <a href=\"http://php.net/countable\"><code>Countable</code></a> and\n+  <a href=\"http://php.net/iteratoraggregate\"><code>IteratorAggregate</code></a>\n+  interfaces. We are going to use three examples in three different languages:\n+  French, Arab and Japanese. Thus:</p>\n+  <pre><code class=\"language-php\">$french   = new Hoa\\String\\String('Je t\\'aime');\n+$arabic   = new Hoa\\String\\String('أحبك');\n+$japanese = new Hoa\\String\\String('私はあなたを愛して');</code></pre>\n+  <p>Now, let's see what we can do on these three strings.</p>\n+\n+  <h3 id=\"String_manipulation\" for=\"main-toc\">String manipulation</h3>\n+\n+  <p>Let's start with <strong>elementary</strong> operations. If we would like\n+  to <strong>count</strong> the number of characters (not bytes), we will use\n+  the <a href=\"http://php.net/count\"><code>count</code> function</a>. Thus:</p>\n+  <pre><code class=\"language-php\">var_dump(\n+    count($french),\n+    count($arabic),\n+    count($japanese)\n+);\n+\n+/**\n+ * Will output:\n+ *     int(9)\n+ *     int(4)\n+ *     int(9)\n+ */</code></pre>\n+  <p>When we speak about text position, it is not suitable to speak about the\n+  right or the left, but rather about a <strong>beginning</strong> or an\n+  <strong>end</strong>, and based on the <strong>direction</strong> of writing.\n+  We can know this direction thanks to the\n+  <code>Hoa\\String\\String::getDirection</code> method. It returns the value of\n+  one of the following constants:</p>\n+  <ul>\n+    <li><code>Hoa\\String\\String::LTR</code>, for left-to-right, if the text is\n+    written from the left to the right,</li>\n+    <li><code>Hoa\\String\\String::RTL</code>, for right-to-left, if the text is\n+    written from the right to the left.</li>\n+  </ul>\n+  <p>Let's observe the result with our examples:</p>\n+  <pre><code class=\"language-php\">var_dump(\n+    $french->getDirection()   === Hoa\\String\\String::LTR, // is left-to-right?\n+    $arabic->getDirection()   === Hoa\\String\\String::RTL, // is right-to-left?\n+    $japanese->getDirection() === Hoa\\String\\String::LTR  // is left-to-right?\n+);\n+\n+/**\n+ * Will output:\n+ *     bool(true)\n+ *     bool(true)\n+ *     bool(true)\n+ */</code></pre>\n+  <p>The result of this method is computed thanks to the\n+  <code>Hoa\\String\\String::getCharDirection</code> static method which computes\n+  the direction of only one character.</p>\n+  <p>If we would like to <strong>concatenate</strong> another string to the end\n+  or to the beginning, we will respectively use the\n+  <code>Hoa\\String\\String::append</code> and\n+  <code>Hoa\\String\\String::prepend</code> methods. These methods, like most of\n+  the ones which modifies the string, return the object itself, in order to\n+  chain the calls. For instance:</p>\n+  <pre><code class=\"language-php\">echo $french->append('… et toi, m\\'aimes-tu ?')->prepend('Mam\\'zelle ! ');\n+\n+/**\n+ * Will output:\n+ *     Mam'zelle ! Je t'aime… et toi, m'aimes-tu ?\n+ */</code></pre>\n+  <p>We also have the <code>Hoa\\String\\String::toLowerCase</code> and\n+  <code>Hoa\\String\\String::toUpperCase</code> methods to, respectively, set the\n+  case of the string to lower or upper. For instance:</p>\n+  <pre><code class=\"language-php\">echo $french->toUpperCase();\n+\n+/**\n+ * Will output:\n+ *     MAM'ZELLE ! JE T'AIME… ET TOI, M'AIMES-TU ?\n+ */</code></pre>\n+  <p>We can also add characters to the beginning or to the end of the string to\n+  reach a <strong>minimum</strong> length. This operation is frequently called\n+  the <em>padding</em> (for historical reasons dating back to typewriters).\n+  That's why we have the <code>Hoa\\String\\String::pad</code> method which takes\n+  three arguments: the minimum length, characters to add and a constant\n+  indicating whether we have to add at the end or at the beginning of the string\n+  (respectively <code>Hoa\\String\\String::END</code>, by default, and\n+  <code>Hoa\\String\\String::BEGINNING</code>).</p>\n+  <pre><code class=\"language-php\">echo $arabic->pad(20, ' ');\n+\n+/**\n+ * Will output:\n+ *                     أحبك\n+ */</code></pre>\n+  <p>A similar operation allows to remove, by default, <strong>spaces</strong>\n+  at the beginning and at the end of the string thanks to the\n+  <code>Hoa\\String\\String::trim</code> method. For example, to retreive our\n+  original Arabic string:</p>\n+  <pre><code class=\"language-php\">echo $arabic->trim();\n+\n+/**\n+ * Will output:\n+ *     أحبك\n+ */</code></pre>\n+  <p>If we would like to remove other characters, we can use its first argument\n+  which must be a regular expression. Finally, its second argument allows to\n+  specify from what side we would like to remove character: at the beginning, at\n+  the end or both, still by using the <code>Hoa\\String\\String::BEGINNING</code>\n+  and <code>Hoa\\String\\String::END</code> constants.</p>\n+  <p>If we would like to remove other characters, we can use its first argument\n+  which must be an regular expression. Finally, its second argument allows to","path":"Documentation/En/Index.xyl","position":146,"original_position":146,"commit_id":"68eef79cbafdf385a0cee9876bba6cc2e6e8d69c","original_commit_id":"68eef79cbafdf385a0cee9876bba6cc2e6e8d69c","user":{"login":"osaris","id":125797,"avatar_url":"https://avatars.githubusercontent.com/u/125797?v=3","gravatar_id":"","url":"https://api.github.com/users/osaris","html_url":"https://github.com/osaris","followers_url":"https://api.github.com/users/osaris/followers","following_url":"https://api.github.com/users/osaris/following{/other_user}","gists_url":"https://api.github.com/users/osaris/gists{/gist_id}","starred_url":"https://api.github.com/users/osaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osaris/subscriptions","organizations_url":"https://api.github.com/users/osaris/orgs","repos_url":"https://api.github.com/users/osaris/repos","events_url":"https://api.github.com/users/osaris/events{/privacy}","received_events_url":"https://api.github.com/users/osaris/received_events","type":"User","site_admin":false},"body":"not sure but it may be \"a regular expression\" rather than \"an\" ?","created_at":"2015-01-10T09:07:41Z","updated_at":"2015-01-10T09:07:41Z","html_url":"https://github.com/hoaproject/String/pull/20#discussion_r22757651","pull_request_url":"https://api.github.com/repos/hoaproject/String/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/hoaproject/String/pulls/comments/22757651"},"html":{"href":"https://github.com/hoaproject/String/pull/20#discussion_r22757651"},"pull_request":{"href":"https://api.github.com/repos/hoaproject/String/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/hoaproject/String/pulls/20","id":27020821,"html_url":"https://github.com/hoaproject/String/pull/20","diff_url":"https://github.com/hoaproject/String/pull/20.diff","patch_url":"https://github.com/hoaproject/String/pull/20.patch","issue_url":"https://api.github.com/repos/hoaproject/String/issues/20","number":20,"state":"open","locked":false,"title":"Translate documentation into English","user":{"login":"Hywan","id":946104,"avatar_url":"https://avatars.githubusercontent.com/u/946104?v=3","gravatar_id":"","url":"https://api.github.com/users/Hywan","html_url":"https://github.com/Hywan","followers_url":"https://api.github.com/users/Hywan/followers","following_url":"https://api.github.com/users/Hywan/following{/other_user}","gists_url":"https://api.github.com/users/Hywan/gists{/gist_id}","starred_url":"https://api.github.com/users/Hywan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hywan/subscriptions","organizations_url":"https://api.github.com/users/Hywan/orgs","repos_url":"https://api.github.com/users/Hywan/repos","events_url":"https://api.github.com/users/Hywan/events{/privacy}","received_events_url":"https://api.github.com/users/Hywan/received_events","type":"User","site_admin":false},"body":"Fix #9.","created_at":"2015-01-08T10:59:21Z","updated_at":"2015-01-10T09:07:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01efebfca58be75078d187d86a38920888059600","assignee":{"login":"Hywan","id":946104,"avatar_url":"https://avatars.githubusercontent.com/u/946104?v=3","gravatar_id":"","url":"https://api.github.com/users/Hywan","html_url":"https://github.com/Hywan","followers_url":"https://api.github.com/users/Hywan/followers","following_url":"https://api.github.com/users/Hywan/following{/other_user}","gists_url":"https://api.github.com/users/Hywan/gists{/gist_id}","starred_url":"https://api.github.com/users/Hywan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hywan/subscriptions","organizations_url":"https://api.github.com/users/Hywan/orgs","repos_url":"https://api.github.com/users/Hywan/repos","events_url":"https://api.github.com/users/Hywan/events{/privacy}","received_events_url":"https://api.github.com/users/Hywan/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/hoaproject/String/pulls/20/commits","review_comments_url":"https://api.github.com/repos/hoaproject/String/pulls/20/comments","review_comment_url":"https://api.github.com/repos/hoaproject/String/pulls/comments/{number}","comments_url":"https://api.github.com/repos/hoaproject/String/issues/20/comments","statuses_url":"https://api.github.com/repos/hoaproject/String/statuses/68eef79cbafdf385a0cee9876bba6cc2e6e8d69c","head":{"label":"Hywan:doc_en","ref":"doc_en","sha":"68eef79cbafdf385a0cee9876bba6cc2e6e8d69c","user":{"login":"Hywan","id":946104,"avatar_url":"https://avatars.githubusercontent.com/u/946104?v=3","gravatar_id":"","url":"https://api.github.com/users/Hywan","html_url":"https://github.com/Hywan","followers_url":"https://api.github.com/users/Hywan/followers","following_url":"https://api.github.com/users/Hywan/following{/other_user}","gists_url":"https://api.github.com/users/Hywan/gists{/gist_id}","starred_url":"https://api.github.com/users/Hywan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hywan/subscriptions","organizations_url":"https://api.github.com/users/Hywan/orgs","repos_url":"https://api.github.com/users/Hywan/repos","events_url":"https://api.github.com/users/Hywan/events{/privacy}","received_events_url":"https://api.github.com/users/Hywan/received_events","type":"User","site_admin":false},"repo":{"id":24115093,"name":"String","full_name":"Hywan/String","owner":{"login":"Hywan","id":946104,"avatar_url":"https://avatars.githubusercontent.com/u/946104?v=3","gravatar_id":"","url":"https://api.github.com/users/Hywan","html_url":"https://github.com/Hywan","followers_url":"https://api.github.com/users/Hywan/followers","following_url":"https://api.github.com/users/Hywan/following{/other_user}","gists_url":"https://api.github.com/users/Hywan/gists{/gist_id}","starred_url":"https://api.github.com/users/Hywan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hywan/subscriptions","organizations_url":"https://api.github.com/users/Hywan/orgs","repos_url":"https://api.github.com/users/Hywan/repos","events_url":"https://api.github.com/users/Hywan/events{/privacy}","received_events_url":"https://api.github.com/users/Hywan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Hywan/String","description":"The Hoa\\String library.","fork":true,"url":"https://api.github.com/repos/Hywan/String","forks_url":"https://api.github.com/repos/Hywan/String/forks","keys_url":"https://api.github.com/repos/Hywan/String/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Hywan/String/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Hywan/String/teams","hooks_url":"https://api.github.com/repos/Hywan/String/hooks","issue_events_url":"https://api.github.com/repos/Hywan/String/issues/events{/number}","events_url":"https://api.github.com/repos/Hywan/String/events","assignees_url":"https://api.github.com/repos/Hywan/String/assignees{/user}","branches_url":"https://api.github.com/repos/Hywan/String/branches{/branch}","tags_url":"https://api.github.com/repos/Hywan/String/tags","blobs_url":"https://api.github.com/repos/Hywan/String/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Hywan/String/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Hywan/String/git/refs{/sha}","trees_url":"https://api.github.com/repos/Hywan/String/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Hywan/String/statuses/{sha}","languages_url":"https://api.github.com/repos/Hywan/String/languages","stargazers_url":"https://api.github.com/repos/Hywan/String/stargazers","contributors_url":"https://api.github.com/repos/Hywan/String/contributors","subscribers_url":"https://api.github.com/repos/Hywan/String/subscribers","subscription_url":"https://api.github.com/repos/Hywan/String/subscription","commits_url":"https://api.github.com/repos/Hywan/String/commits{/sha}","git_commits_url":"https://api.github.com/repos/Hywan/String/git/commits{/sha}","comments_url":"https://api.github.com/repos/Hywan/String/comments{/number}","issue_comment_url":"https://api.github.com/repos/Hywan/String/issues/comments/{number}","contents_url":"https://api.github.com/repos/Hywan/String/contents/{+path}","compare_url":"https://api.github.com/repos/Hywan/String/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Hywan/String/merges","archive_url":"https://api.github.com/repos/Hywan/String/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Hywan/String/downloads","issues_url":"https://api.github.com/repos/Hywan/String/issues{/number}","pulls_url":"https://api.github.com/repos/Hywan/String/pulls{/number}","milestones_url":"https://api.github.com/repos/Hywan/String/milestones{/number}","notifications_url":"https://api.github.com/repos/Hywan/String/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Hywan/String/labels{/name}","releases_url":"https://api.github.com/repos/Hywan/String/releases{/id}","created_at":"2014-09-16T19:46:05Z","updated_at":"2014-08-15T16:26:07Z","pushed_at":"2015-01-09T21:53:25Z","git_url":"git://github.com/Hywan/String.git","ssh_url":"git@github.com:Hywan/String.git","clone_url":"https://github.com/Hywan/String.git","svn_url":"https://github.com/Hywan/String","homepage":"http://hoa-project.net/","size":318,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hoaproject:master","ref":"master","sha":"c3e510b9aaf685e9bba2dcddd7ee23850faddfe4","user":{"login":"hoaproject","id":1519718,"avatar_url":"https://avatars.githubusercontent.com/u/1519718?v=3","gravatar_id":"","url":"https://api.github.com/users/hoaproject","html_url":"https://github.com/hoaproject","followers_url":"https://api.github.com/users/hoaproject/followers","following_url":"https://api.github.com/users/hoaproject/following{/other_user}","gists_url":"https://api.github.com/users/hoaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/hoaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoaproject/subscriptions","organizations_url":"https://api.github.com/users/hoaproject/orgs","repos_url":"https://api.github.com/users/hoaproject/repos","events_url":"https://api.github.com/users/hoaproject/events{/privacy}","received_events_url":"https://api.github.com/users/hoaproject/received_events","type":"Organization","site_admin":false},"repo":{"id":5538851,"name":"String","full_name":"hoaproject/String","owner":{"login":"hoaproject","id":1519718,"avatar_url":"https://avatars.githubusercontent.com/u/1519718?v=3","gravatar_id":"","url":"https://api.github.com/users/hoaproject","html_url":"https://github.com/hoaproject","followers_url":"https://api.github.com/users/hoaproject/followers","following_url":"https://api.github.com/users/hoaproject/following{/other_user}","gists_url":"https://api.github.com/users/hoaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/hoaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoaproject/subscriptions","organizations_url":"https://api.github.com/users/hoaproject/orgs","repos_url":"https://api.github.com/users/hoaproject/repos","events_url":"https://api.github.com/users/hoaproject/events{/privacy}","received_events_url":"https://api.github.com/users/hoaproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoaproject/String","description":"The Hoa\\String library.","fork":false,"url":"https://api.github.com/repos/hoaproject/String","forks_url":"https://api.github.com/repos/hoaproject/String/forks","keys_url":"https://api.github.com/repos/hoaproject/String/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoaproject/String/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoaproject/String/teams","hooks_url":"https://api.github.com/repos/hoaproject/String/hooks","issue_events_url":"https://api.github.com/repos/hoaproject/String/issues/events{/number}","events_url":"https://api.github.com/repos/hoaproject/String/events","assignees_url":"https://api.github.com/repos/hoaproject/String/assignees{/user}","branches_url":"https://api.github.com/repos/hoaproject/String/branches{/branch}","tags_url":"https://api.github.com/repos/hoaproject/String/tags","blobs_url":"https://api.github.com/repos/hoaproject/String/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoaproject/String/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoaproject/String/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoaproject/String/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoaproject/String/statuses/{sha}","languages_url":"https://api.github.com/repos/hoaproject/String/languages","stargazers_url":"https://api.github.com/repos/hoaproject/String/stargazers","contributors_url":"https://api.github.com/repos/hoaproject/String/contributors","subscribers_url":"https://api.github.com/repos/hoaproject/String/subscribers","subscription_url":"https://api.github.com/repos/hoaproject/String/subscription","commits_url":"https://api.github.com/repos/hoaproject/String/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoaproject/String/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoaproject/String/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoaproject/String/issues/comments/{number}","contents_url":"https://api.github.com/repos/hoaproject/String/contents/{+path}","compare_url":"https://api.github.com/repos/hoaproject/String/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoaproject/String/merges","archive_url":"https://api.github.com/repos/hoaproject/String/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoaproject/String/downloads","issues_url":"https://api.github.com/repos/hoaproject/String/issues{/number}","pulls_url":"https://api.github.com/repos/hoaproject/String/pulls{/number}","milestones_url":"https://api.github.com/repos/hoaproject/String/milestones{/number}","notifications_url":"https://api.github.com/repos/hoaproject/String/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoaproject/String/labels{/name}","releases_url":"https://api.github.com/repos/hoaproject/String/releases{/id}","created_at":"2012-08-24T10:31:31Z","updated_at":"2015-01-07T10:01:58Z","pushed_at":"2015-01-07T10:01:57Z","git_url":"git://github.com/hoaproject/String.git","ssh_url":"git@github.com:hoaproject/String.git","clone_url":"https://github.com/hoaproject/String.git","svn_url":"https://github.com/hoaproject/String","homepage":"http://hoa-project.net/","size":636,"stargazers_count":28,"watchers_count":28,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hoaproject/String/pulls/20"},"html":{"href":"https://github.com/hoaproject/String/pull/20"},"issue":{"href":"https://api.github.com/repos/hoaproject/String/issues/20"},"comments":{"href":"https://api.github.com/repos/hoaproject/String/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/hoaproject/String/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/hoaproject/String/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/hoaproject/String/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/hoaproject/String/statuses/68eef79cbafdf385a0cee9876bba6cc2e6e8d69c"}}}}