cvs: phpdoc /ja/functions array.xml mbstring.xml misc.xml

From: Date: Sun, 24 Jun 2001 07:06:31 +0000
Subject: cvs: phpdoc /ja/functions array.xml mbstring.xml misc.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969335586@lists.php.net to get a copy of this message
hirokawa Sun Jun 24 09:06:31 2001 EDT Added files: /phpdoc/ja/functions mbstring.xml Modified files: /phpdoc/ja/functions array.xml misc.xml Log: added: mbstring.xml

Index: phpdoc/ja/functions/array.xml diff -u phpdoc/ja/functions/array.xml:1.26 phpdoc/ja/functions/array.xml:1.27 --- phpdoc/ja/functions/array.xml:1.26 Sat Apr 28 04:20:55 2001 +++ phpdoc/ja/functions/array.xml Sun Jun 24 09:06:31 2001 @@ -1245,7 +1245,7 @@ <refentry id="function.array-unshift"> <refnamediv> <refname>array_unshift</refname> - <refpurpose>一つ以上の要素を鍥ȗの最初に加える</refpurpose> + <refpurpose> 一つ以上の要素を 配列の 最初に加える </refpurpose> </refnamediv> <refsect1> <title>説明</title> @@ -1263,7 +1263,7 @@ </funcsynopsis> <para> <function>array_unshift</function>は、<parameter>array</parameter> - の先頭に渡された要素を劈ます。リストの要素は全体として加えられるため、 + の先頭に指定された要素を加えます。リストの要素は全体として加えられるため、 加えられた要素の順番は変わらないことに注意してください。 </para> <para> @@ -2844,7 +2844,7 @@ <para> 比較関数は、最初の引数が二番目の引数より小さいか等しいか大きい場合に それぞれゼロ未満、ゼロに等しい、ゼロより大きい整数を返します。二つの - メンバーのϔ較結果が等しいとなった場合、ソートされた配列の順番は定義 + メンバーの?較結果が等しいとなった場合、ソートされた配列の順番は定義 されません。 <example> <title><function>usort</function>の例</title> Index: phpdoc/ja/functions/misc.xml diff -u phpdoc/ja/functions/misc.xml:1.19 phpdoc/ja/functions/misc.xml:1.20 --- phpdoc/ja/functions/misc.xml:1.19 Sun Jun 3 02:51:43 2001 +++ phpdoc/ja/functions/misc.xml Sun Jun 24 09:06:31 2001 @@ -198,8 +198,7 @@ </example> </para> <para> - <function>define</function> は成功時にtrue、エラー発生時にfalseを - 返します。 + <function>define</function> は成功時に<constant>TRUE</constant>、エラー発生時に<constant>FALSE</constant>を返します。 </para> <para> <function>defined</function>, Index: phpdoc/ja/functions/mbstring.xml +++ phpdoc/ja/functions/mbstring.xml <reference id="ref.mbstring"> <title>マルチバイト文字列関数</title> <titleabbrev> マルチバイト文字列 </titleabbrev> <partintro> <sect1 id="mb-intro"> <title>導入</title> <warning> <simpara> このモジュールは、実験的なステータスにあります。関数名/APIは変更 される可能性があります。現在の変換フィルタは日本語のみをサポート しています。 </simpara> </warning> <para> 全ての文字をシングルバイトで表現可能な言語は数多くあります。マル チバイト文字コードは、多くの言語で文字を表すために使用されていま す。<literal>mbstring</literal> は日本語文字を処理するために開発 されました。しかし、<literal>mbstring</literal> 関数の多くは、日 本語以外の文字エンコーディングも処理することが可能です。 </para> <para> マルチバイト文字エンコーディングは、バイトの並びで単一の文字を表 現します。いくつかの文字エンコーディングでは、マルチバイト文字列 の始まり/終わりを表すためにシフト(エスケープ)シーケンスが使用され ています。この場合、マルチバイト文字エンコーディングに対応した方 法でない限り、分割または追加されるとマルチバイト文字列は壊れてし まう可能性があります。このモジュールは、マルチバイト文字列に対応 した文字列関数および変換関数のようなその他のユーティリティ関数を 提供します。 </para> <para> PHPは、基本的にISO-8859-1用に設計されているため、いくつかのマルチ バイト文字エンコーディングは、PHPで上手く動作しません。このため、 <literal>mbstring.internal_encoding</literal> にPHPで動作する文字 エンコーディングを設定することが必要です。 </para> <para> PHP4 文字エンコーディング規約 </para> <para> <itemizedlist> <listitem> <simpara> バイト毎のエンコーディング </simpara> </listitem> <listitem> <simpara> シングルバイト文字は、<literal>ASCII</literal>互換の <literal>00h-7fh</literal>の範囲にある。 </simpara> </listitem> <listitem> <simpara> マルチバイト文字は、<literal>00h-7fh</literal>以外を使用 </simpara> </listitem> </itemizedlist> </para> <para> PHPで動作する内部エンコーディングと動作しない文字エンコーディング の例を以下に示します。 <informalexample> <programlisting> PHPで動作する文字エンコーディング: ISO-8859-*, EUC-JP, UTF-8 PHPで動作しない文字エンコーディング: JIS, SJIS </programlisting> </informalexample> </para> <para> PHPで動作しない文字エンコーディングは、 <literal>mbstring</literal>のHTTP入力/出力変換機能/関数により変換 することが可能です。 </para> <note> <para> SJIS は、読者がパーサ/コンパイラ、文字エンコーディングと文字エン コーディングの問題点について精通していない限り内部エンコーディン グとして使用するべきではありません。 </para> </note> <note> <para> PHPでデータベースを使用する場合、性能を向上させるためにデータベー スのとPHPの内部エンコーディングで同じ文字エンコーディングを使用 することを推奨します。 </para> <para> PostgreSQLを使用している場合、バックエンドの文字エンコーディング と異なる文字エンコーディングを使用することが可能です。詳細につい ては、PostgreSQLのマニュアルを参照下さい。 </para> </note> <sect2 id="mb-enable"> <title>mbstringの使用法</title> <para> <literal>mbstring</literal> は拡張モジュールです。 <literal>configure</literal>スクリプトでモジュールを有効にする必 要があります。詳細については、<link linkend="installation">インストール</link>の節を参照下さい。 </para> <simpara> 以下のconfigureオプションが<literal>mbstring</literal>モジュール に関係するものです。 </simpara> <para> <itemizedlist> <listitem> <para> <option role="configure">--enable-mbstring</option> : <literal>mbstring</literal> 関数を有効にします。このオプショ ンは、<literal>mbstring</literal> 関数を利用するために必要で す。 </para> </listitem> <listitem> <para> <option role="configure">--enable-mbstr-enc-trans</option> : <literal>mbstring</literal>変換エンジンを使用したHTTP入力の文 字エンコーディング変換を有効にします。この機能が有効の場合、 HTTP入力文字エンコーディングは、自動的に <literal>mbstring.internal_encoding</literal>に変換されます。 </para> </listitem> </itemizedlist> </para> </sect2> <sect2 id="mb-conv"> <title>HTTP入出力</title> <para> HTTP 入出力の文字エンコーディング変換はバイナリデータも変換して しまいます。HTTP入出力にバイナリデータが使用される場合、ユーザは、 文字エンコーディング変換を制御する必要があります。 </para> <para> HTMLフォームの<literal>enctype</literal>が <literal>multipart/form-data</literal>に設定された場合、 <literal>mbstring</literal> は、POSTデータの文字エンコーディング を変換しません。この場合、文字列を内部文字エンコーディングに変換 してやる必要があります。 </para> <para> <itemizedlist> <listitem> <simpara> HTTP入力 </simpara> <para> PHPスクリプトでHTTP入力文字変換を制御する手段はありません。 HTTP入力文字変換を無効にするには、<literal>php.ini</literal> で行う必要があります。 <example> <title>php.iniでHTTP入力変換を無効にする</title> <programlisting role="php"> mbstring.http_input = pass </programlisting> </example> </para> <para> PHPをApacheモジュールで使用する場合、php.iniの設定を <literal>httpd.conf</literal>により仮想ホスト単位で、または <literal>.htaccess</literal>によりディレクトリ単位で上書きす ることが可能です。詳細は、<link linkend="configuration">設定 </link>の節およびApacheマニュアルを参照下さい。 </para> </listitem> <listitem> <simpara> HTTP出力 </simpara> <para> 出力の文字エンコーディング変換を有効にする方法は複数あります。 一つ目は <literal>php.ini</literal>、もう1つは <function>ob_start</function> で <literal>ob_start</literal> のコールバック関数として <function>mb_output_handler</function> を指定するものです。 </para> <note> <para> PHP3-i18nのユーザにとっては、<literal>mbstring</literal>の出 力変換は、PHP3-i18nとは異なっています。文字エンコーディング は、出力のバッファリング機能を使用して変換されます。 </para> </note> </listitem> </itemizedlist> </para> <para> <example> <title><literal>php.ini</literal>の設定例</title> <programlisting role="php"> ;; 全てのPHPページで出力の文字エンコーディング変換を有効にする ;; 出力バッファリングを有効にする output_buffering = On ;; mb_output_handlerによる出力変換を有効にする output_handler = mb_output_handler </programlisting> </example> </para> <para> <example> <title>スクリプトの例</title> <programlisting role="php"> &lt;?php // このページでのみ出力の文字エンコーディング変換を有効にする // HTTP 出力文字エンコーディングをSJISに設定する mb_http_output('SJIS'); // 出力のバッファリングを開始し、コールバック関数として"mb_output_handler" // を指定する ob_start('mb_output_handler'); ?&gt; </programlisting> </example> </para> </sect2> <sect2 id="mb-code"> <title>サポートされる文字エンコーディング</title> <simpara> 現在、以下の文字エンコーディングが<literal>mbstring</literal>モ ジュールによりサポートされています。文字エンコーディングは、 <literal>mbstring</literal>関数の<literal>encoding</literal>パラ メータで指定することが可能です。 </simpara> <para> 以下の文字エンコーディングがこのPHP拡張モジュールでサポートされ ています。 </para> <para> <literal>UCS-4</literal>, <literal>UCS-4BE</literal>, <literal>UCS-4LE</literal>, <literal>UCS-2</literal>, <literal>UCS-2BE</literal>, <literal>UCS-2LE</literal>, <literal>UTF-32</literal>, <literal>UTF-32BE</literal>, <literal>UTF-32LE</literal>, <literal>UCS-2LE</literal>, <literal>UTF-16</literal>, <literal>UTF-16BE</literal>, <literal>UTF-16LE</literal>, <literal>UTF-8</literal>, <literal>UTF-7</literal>, <literal>ASCII</literal>, <literal>EUC-JP</literal>, <literal>SJIS</literal>, <literal>eucJP-win</literal>, <literal>SJIS-win</literal>, <literal>ISO-2022-JP</literal>, <literal>JIS</literal>, <literal>ISO-8859-1</literal>, <literal>ISO-8859-2</literal>, <literal>ISO-8859-3</literal>, <literal>ISO-8859-4</literal>, <literal>ISO-8859-5</literal>, <literal>ISO-8859-6</literal>, <literal>ISO-8859-7</literal>, <literal>ISO-8859-8</literal>, <literal>ISO-8859-9</literal>, <literal>ISO-8859-10</literal>, <literal>ISO-8859-13</literal>, <literal>ISO-8859-14</literal>, <literal>ISO-8859-15</literal>, <literal>byte2be</literal>, <literal>byte2le</literal>, <literal>byte4be</literal>, <literal>byte4le</literal>, <literal>BASE64</literal>, <literal>7bit</literal>, <literal>8bit</literal>, <literal>UTF7-IMAP</literal> </para> <para> エンコーディング名を指定可能な<literal>php.ini</literal> のエン トリでは、&quot;<literal>auto</literal>&quot; および &quot;<literal>pass</literal>&quot; も指定可能です。 <literal>mbstring</literal> 関数には、エンコーディング名と quot;<literal>auto</literal>&quot; を指定可能です。 </para> <para> &quot;<literal>pass</literal>&quot; が指定された場合、文字エンコー ディング変換は行われません。 </para> <para> &quot;<literal>auto</literal>&quot; が指定された場合、この文字列 は、&quot;<literal>ASCII,JIS,UTF-8,EUC-JP,SJIS</literal>&quot;に 変換されます。 </para> <para> <function>mb_detect_order</function>も参照下さい。 </para> <note> <para> &quot;サポートされる文字エンコーディング&quot; は、内部文字コー ドとして動作するものとは異なります。 </para> </note> </sect2> <sect2 id="mb-ini"> <title>php.iniの設定</title> <para> <itemizedlist> <listitem> <simpara> <literal>mbstring.internal_encoding</literal> は内部文字エン コーディングのデフォルト値を定義します。 </simpara> </listitem> <listitem> <simpara> <literal>mbstring.http_input</literal> はHTTP入力文字エンコー ディングのデフォルト値を定義します。 </simpara> </listitem> <listitem> <simpara> <literal>mbstring.http_output</literal> は、HTTP出力文字エン コーディングのデフォルト値を定義します。 </simpara> </listitem> <listitem> <simpara> <literal>mbstring.detect_order</literal> は、文字コード検出の デフォルト値を定義します。 <function>mb_detect_order</function>も参照下さい。 </simpara> </listitem> <listitem> <simpara> <literal>mbstring.substitute_character</literal> は、無効な文 字を代替する文字を定義します。 </simpara> </listitem> </itemizedlist> </para> <para> Webブラウザは、フォームのデータを投稿する際に同じ文字エンコーディ ングを使用すると仮定されます。しかし、ブラウザは同じ文字エンコー ディングを使用しない可能性があります。ブラウザで使用される文字エ ンコーディングを検出するには、<function>mb_http_input</function> を参照下さい。 </para> <para> HTMLフォームで<literal>enctype</literal> が <literal>multipart/form-data</literal> に設定された場合、 <literal>mbstring</literal>はPOSTデータの文字エンコーディングを 変換しません。ユーザは、変換に応じてスクリプト内で変換を行う必要 があります。 </para> <para> しかし、ブラウザ側でもHTML内の文字エンコーディングを検出すること は可能です。HTMLヘッダで<literal>charset</literal>を設定する方が より良いでしょう。文字エンコーディングに応じて <literal>default_charset</literal>を変更して下さい。 </para> <para> <example> <title><literal>php.ini</literal>設定の例</title> <programlisting role="php"> ;; デフォルトの内部エンコーディングを設定 ;; 注意: PHPで動作する文字エンコーディングを使用すること mbstring.internal_encoding = UTF-8 ; 内部エンコーディングをUTF-8に設定 ;; デフォルトのHTTP入力文字エンコーディングを設定 ;; 注意: スクリプトではhttp_inputの設定は変更できません。 mbstring.http_input = pass ; 変換しない。 mbstring.http_input = auto ; HTTP入力をautoに設定 ; "auto" は、"ASCII,JIS,UTF-8, ; EUC-JP,SJIS"に展開されます。 mbstring.http_input = SJIS ; HTTP入力をSJISに設定 mbstring.http_input = UTF-8,SJIS,EUC-JP ; 順番を指定 ;; デフォルトのHTTP出力文字エンコーディングを設定 mbstring.http_output = pass ; 変換せず mbstring.http_output = UTF-8 ; HTTP出力エンコーディングをUTF-8に指定 ;; デフォルトの文字エンコーディング検出順序を設定 mbstring.detect_order = auto ; デフォルトの順番をautoに設定 mbstring.detect_order = ASCII,JIS,UTF-8,SJIS,EUC-JP ; 順番を指定 ;; 代替文字のデフォルト値を設定 mbstring.substitute_character = 12307 ; Unicode値を指定 mbstring.substitute_character = none ; 文字を出力しない mbstring.substitute_character = long ; longの例: U+3000,JIS+7E7E </programlisting> </example> </para> <para> <example> <title> <literal>EUC-JP</literal> ユーザ用の<literal>php.ini</literal> の設定 </title> <programlisting role="php"> ;; 出力バッファリングを無効にする output_buffering = Off ;; HTTP charsetヘッダを設定 default_charset = EUC-JP ;; HTTP 入力エンコーディング変換をautoに設定 mbstring.http_input = auto ;; HTTP出力をEUC-JPに設定 mbstring.http_output = EUC-JP ;; 内部エンコーディングをEUC-JPに設定 mbstring.internal_encoding = EUC-JP ;; 無効な文字を出力しない mbstring.substitute_character = none </programlisting> </example> </para> <para> <example> <title> <literal>SJIS</literal>ユーザ用の<literal>php.ini</literal>の 設定 </title> <programlisting role="php"> ;; 出力のバッファリングを有効に output_buffering = On ;; 出力の変換を有効にするために mb_output_handler を設定 output_handler = mb_output_handler ;; HTTPヘッダ charset を設定 default_charset = Shift_JIS ;; HTTP入力エンコーディング変換をautoに設定 mbstring.http_input = auto ;; SJISに変換 mbstring.http_output = SJIS ;; 内部エンコーディングをEUC-JPに設定 mbstring.internal_encoding = EUC-JP ;; 無効な文字を出力しない mbstring.substitute_character = none </programlisting> </example> </para> </sect2> <sect2 id="mb-ja-basic"> <title>日本語のマルチバイト文字に関する基本事項</title> <para> 多くの日本語の文字は1文字あたり複数のバイトを必要とします。加え て、日本語の環境では複数の文字エンコーディング手法が使用されてい ます。使用されているのは、EUC-JP、Shift_JIS(SJIS)、 ISO-2022-JP(JIS) 文字エンコーディングです。Unicodeが普及しつつあ り、UTF-8 も使用されています。日本語環境のWebアプリケーションを 開発するためには、HTTP入出力、RDBMS、e-mailの処理においてそれぞ れに適した文字集合を使用することが重要となります。 </para> <para> <itemizedlist> <listitem> <simpara> 1文字は最大4バイトになる </simpara> </listitem> <listitem> <simpara> マルチバイト文字は通常シングルバイト文字の2倍の幅となります。 広い幅の文字は「全角」、狭い幅の文字は「半角」と呼ばれます。 通常、「全角」文字は固定幅です。 </simpara> </listitem> <listitem> <simpara> いくつかの文字エンコーディングでは、マルチバイト文字列を開始/ 終了するためのシフト(エスケープ)シーケンスが定義されています。 </simpara> </listitem> <listitem> <simpara> SMTP/NNTPでは、ISO-2022-JP を使用する必要があります。 </simpara> </listitem> <listitem> <para> &quot;i-mode&quot; 用Webサイトは、SJISを使用する必要がありま す。 </para> </listitem> </itemizedlist> </para> </sect2> <sect2 id="mb-ref"> <title>リファレンス</title> <para> マルチバイト文字エンコーディングと関連する問題は非常に複雑です。 ここで詳細について記述することは不可能です。詳細な事項については、 以下のURLおよび他のリソースを参照下さい。 <itemizedlist> <listitem> <para> Unicode/UTF/UCS/等 </para> <para> <literal>http://www.unicode.org/</literal> </para> </listitem> <listitem> <para> 日本語/韓国語/中国語文字に関する情報 </para> <para> <literal> ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/cjk.inf </literal> </para> </listitem> </itemizedlist> </para> </sect2> </sect1> </partintro> <refentry id="function.mb-language"> <refnamediv> <refname>mb_language</refname> <refpurpose> カレントの言語を設定/取得 </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_language</function></funcdef> <paramdef>string <parameter><optional>language</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_language</function> は言語を設定します。 <parameter>language</parameter> が省略された場合、カレントの言語 を文字列で返します。 </para> <para> この<parameter>language</parameter>が、e-mailメッセージのエンコー ディングとして使用されます。有効な言語は、"Japanese", "ja","English","en", "uni" (UTF-8) です。 <function>mb_send_mail</function> は、e-mailをエンコードする際に この設定を使用します。 </para> <para> 言語とその設定は、Japaneseの場合はISO-2022-JP/Base64、uniの場合は UTF-8/Base64、Englishの場合はISO-8859-1/quoted printableです。 </para> <para> 返り値: <parameter>language</parameter> が設定され、 <parameter>language</parameter> が有効な場合、TRUEが返されます。 そうでない場合、FALSEが返されます。 <parameter>language</parameter> が省略された場合、言語の名前が文 字列として返されます。事前に言語が設定されていない場合、FALSEが返 されます。 </para> <para> <function>mb_send_mail</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-parse-str"> <refnamediv> <refname>mb_parse_str</refname> <refpurpose> GET/POST/COOKIEデータをパースし、グローバル変数を設定する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_parse_str</function> </funcdef> <paramdef>string <parameter>encoded_string</parameter> </paramdef> <paramdef>array <parameter><optional>result</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_parse_str</function> は、GET/POST/COOKIE データをパー スし、グローバル変数を設定します。PHPは、生のPOST/COOKIEを提供し ないため、原状ではGETデータでのみ使用可能です。この関数は、URLエ ンコードされたデータをパース、エンコーディングを検出、内部エンコー ディングへ変換し、配列<parameter>result</parameter>またはグローバ ル配列に設定します。 </para> <para> <parameter>encoded_string</parameter>: URLエンコードされたデータ。 </para> <para> <parameter>result</parameter>: デコードされ、文字エンコーディング 変換された文字列が含まれます。 </para> <para> 返り値: 成功時にTRUE、失敗した場合にFALSE。 </para> <para> <function>mb_detect_order</function>, <function>mb_internal_encoding</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-internal-encoding"> <refnamediv> <refname>mb_internal_encoding</refname> <refpurpose> 内部文字エンコーディングの設定/取得 </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_internal_encoding</function></funcdef> <paramdef>string <parameter><optional>encoding</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_internal_encoding</function>は、内部文字エンコーディ ングを<parameter>encoding</parameter>に設定します。パラメータが省 略された場合、カレントの内部エンコーディングを返します。 </para> <para> <parameter>encoding</parameter>は、HTTP入力文字エンコーディング変 換、HTTP出力文字エンコーディング変換およびmbstringモジュールによ り定義された文字列関数においてデフォルトの文字エンコーディングと して使用されます。 </para> <para> <parameter>encoding</parameter>: 文字エンコーディング名 </para> <para> 返り値: <parameter>encoding</parameter>が設定された場合、 <function>mb_internal_encoding</function> は成功時に <literal>TRUE</literal>、そうでない場合に<literal>FALSE</literal> を返します。<parameter>encoding</parameter>が省略された場合、カレ ントの文字エンコーディング名を返します。 </para> <para> <example> <title><function>mb_internal_encoding</function>の例</title> <programlisting role="php"> /* 内部文字エンコーディングをUTF-8に設定 */ mb_internal_encoding("UTF-8"); /* カレントの内部文字エンコーディングを表示 */ echo mb_internal_encoding(); </programlisting> </example> </para> <para> <function>mb_http_input</function>, <function>mb_http_output</function>, <function>mb_detect_order</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-http-input"> <refnamediv> <refname>mb_http_input</refname> <refpurpose>HTTP入力文字エンコーディングの検出</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_http_input</function></funcdef> <paramdef>string <parameter><optional>type</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <simpara> <function>mb_http_input</function>は、HTTP入力文字エンコーディン グを検出した結果を返します。 </simpara> <para> <parameter>type</parameter>: HTTP入力の型を表す文字列を入力して下 さい。GETの場合は &quot;G&quot;、POSTの場合は &quot;P&quot;、 COOKIEの場合は &quot;C&quot;。<parameter>type</parameter>が省略さ れた場合、直近に処理された入力型が返されます。 </para> <para> 返り値: 文字エンコーディング名。 <function>mb_http_input</function>が指定したHTTP入力の処理を行っ ていない場合、FALSEが返されます。 </para> <para> <function>mb_internal_encoding</function>, <function>mb_http_output</function>, <function>mb_detect_order</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-http-output"> <refnamediv> <refname>mb_http_output</refname> <refpurpose>HTTP出力文字エンコーディングの設定/取得</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_http_output</function></funcdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <parameter>encoding</parameter> が設定された場合、 <function>mb_http_output</function> は HTTP出力文字エンコーディン グを<parameter>encoding</parameter>に設定します。この関数を実行し た後、出力は<parameter>encoding</parameter>に変換されます。 <function>mb_http_output</function>は成功時に <literal>TRUE</literal>、失敗時に<literal>FALSE</literal>を返しま す。 </para> <para> <parameter>encoding</parameter>が省略された場合、 <function>mb_http_output</function>はカレントのHTTP出力文字エンコー ディングを返します。 </para> <para> <function>mb_internal_encoding</function>, <function>mb_http_input</function>, <function>mb_detect_order</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-detect-order"> <refnamediv> <refname>mb_detect_order</refname> <refpurpose> 文字エンコーディング検出順序の設定/取得 </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>array <function>mb_detect_order</function></funcdef> <paramdef>mixed <parameter><optional>encoding-list</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_detect_order</function>は、自動文字エンコーディング 検出の順番を<parameter>encoding-list</parameter>に設定します。 成功時に<literal>TRUE</literal>、失敗時に <literal>FALSE</literal>を返します。 </para> <para> <parameter>encoding-list</parameter>は配列またはカンマ区切りの文 字エンコーディングのリストです。("auto" は、 "ASCII, JIS, UTF-8, EUC-JP, SJIS"に展開されます。) </para> <para> <parameter>encoding-list</parameter> が省略された場合、カレントの 文字エンコーディング検出順が配列で返されます。 </para> <para> この設定は、<function>mb_detect_encoding</function> および <function>mb_send_mail</function>に影響します。 </para> <note> <para> <literal>mbstring</literal> は現在次のエンコーディングを検出する フィルタを実装しています。以下のエンコーディングに無効なバイトシー ケンスがあった場合、エンコーディング検出は失敗します。 </para> <simpara> <literal>UTF-8</literal>, <literal>UTF-7</literal>, <literal>ASCII</literal>, <literal>EUC-JP</literal>,<literal>SJIS</literal>, <literal>eucJP-win</literal>, <literal>SJIS-win</literal>, <literal>JIS</literal>, <literal>ISO-2022-JP</literal> </simpara> <para> <literal>ISO-8859-*</literal>の場合、<literal>mbstring</literal> は常に<literal>ISO-8859-*</literal>として検出します。 </para> <para> <literal>UTF-16</literal>, <literal>UTF-32</literal>, <literal>UCS2</literal>,<literal>UCS4</literal>の場合、エンコー ディング検出は常に失敗します。 </para> <para> <example> <title>無意味な順番の例</title> <programlisting> ; 常にISO-8859-1として検出される detect_order = ISO-8859-1, UTF-8 ; ASCII/UTF-7の値はUTF-8として有効なため、常にUTF-8として検出される。 detect_order = UTF-8, ASCII, UTF-7 </programlisting> </example> </para> </note> <para> <example> <title><function>mb_detect_order</function>の例</title> <programlisting role="php"> /* リストで検出順を設定 */ mb_detect_order("eucjp-win,sjis-win,UTF-8"); /* 配列で検出順を設定 */ $ary[] = "ASCII"; $ary[] = "JIS"; $ary[] = "EUC-JP"; mb_detect_order($ary); /* カレントの検出順を表示 */ echo implode(", ", mb_detect_order()); </programlisting> </example> </para> <para> <function>mb_internal_encoding</function>, <function>mb_http_input</function>, <function>mb_http_output</function>, <function>mb_send_mail</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-substitute-character"> <refnamediv> <refname>mb_substitute_character</refname> <refpurpose>置換文字の設定/入手</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>mb_substitute_character</function></funcdef> <paramdef>mixed <parameter><optional>substrchar</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_substitute_character</function> は、入力文字エンコー ディングが無効または出力文字エンコーディングに文字コードが存在し ない場合の代替文字を指定します。無効な文字は、ヌル(出力しない)、 文字列または整数値(Unicode文字コード値)に置換することが可能です。 </para> <para> この設定は、<function>mb_detect_encoding</function>および <function>mb_send_mail</function>に影響します。 </para> <para> <parameter>substchar</parameter> : Unicode値の整数または文字列を 以下のように指定します。 <itemizedlist> <listitem> <simpara> &quot;none&quot; : 出力しない </simpara> </listitem> <listitem> <simpara> &quot;long&quot; : 出力する文字コード値 (例: U+3000,JIS+7E7E) </simpara> </listitem> </itemizedlist> </para> <para> 返り値: <parameter>substchar</parameter> が設定された場合、成功時 に <literal>TRUE</literal>、そうでない場合に <literal>FALSE</literal>が返されます。 <parameter>substchar</parameter>が設定されない場合、Unicode値また は &quot;<literal>none</literal>&quot;/&quot;<literal>long</literal>&quot; が返されます。 </para> <para> <example> <title><function>mb_substitute_character</function> の例</title> <programlisting role="php"> /* Unicode U+3013 (〓)を設定 */ mb_substitute_character(0x3013); /* HEXフォーマットを設定 */ mb_substitute_character("long"); /* カレントの設定を表示 */ echo mb_substitute_character(); </programlisting> </example> </para> </refsect1> </refentry> <refentry id="function.mb-output-handler"> <refnamediv> <refname>mb_output_handler</refname> <refpurpose> 出力バッファ内で文字エンコーディングを変換するコールバック関数 </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_output_handler</function></funcdef> <paramdef>string <parameter>contents</parameter></paramdef> <paramdef>int <parameter>status</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_output_handler</function> は、 <function>ob_start</function> のコールバック関数です。 <function>mb_output_handler</function> は、出力バッファの文字を内 部文字エンコーディングからHTTP出力文字エンコーディングに変換しま す。 </para> <para> 4.0.6 以降のバージョンでは、以下の条件が満たされた場合にこのハン ドラはcharset HTTP ヘッダを設定します。 </para> <para> <itemizedlist> <listitem> <simpara> header()で<literal>Content-Type</literal>が設定されていない場 合 </simpara> </listitem> <listitem> <simpara> デフォルトのMIME型が<literal>text/</literal>で始まる </simpara> </listitem> <listitem> <simpara> <literal>http_output</literal> の設定がpass以外 </simpara> </listitem> </itemizedlist> </para> <para> <parameter>contents</parameter> : 出力バッファの内容 </para> <para> <parameter>status</parameter> : 出力バッファのステータス </para> <para> 返り値: 変換後の文字列 </para> <para> <example> <title><function>mb_output_handler</function>の例</title> <programlisting role="php"> mb_http_output("UTF-8"); ob_start("mb_output_handler"); </programlisting> </example> </para> <note> <para> イメージのようなバイナリデータをPHPスクリプトから出力したい場合、 <function>mb_http_output</function>を用いて出力エンコーディング を&quot;pass&quot;にし、変換を無効とする必要があります。 </para> </note> <para> <function>ob_start</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-preferred-mime-name"> <refnamediv> <refname>mb_preferred_mime_name</refname> <refpurpose>MIME文字設定を文字列で得る</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_preferred_mime_name</function></funcdef> <paramdef>string <parameter>encoding</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_preferred_mime_name</function> は、文字エンコーディ ング<parameter>encoding</parameter>用の MIME<literal>charset</literal>文字列を返します。 <literal>charset</literal>用の文字列が返されます。 </para> <para> <example> <title><function>mb_preferred_mime_string</function>の例</title> <programlisting role="php"> $outputenc = "sjis-win"; mb_http_output($outputenc); ob_start("mb_output_handler"); Header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc)); </programlisting> </example> </para> </refsect1> </refentry> <refentry id="function.mb-strlen"> <refnamediv> <refname>mb_strlen</refname> <refpurpose>文字列の長さを得る</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_strlen</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_strlen</function> は、文字エンコーディング <parameter>encoding</parameter>の文字列<parameter>str</parameter> の文字数を返します。マルチバイト文字の一文字は1個として数えられま す。 </para> <para> <parameter>encoding</parameter> は、<parameter>str</parameter>用 の文字エンコーディングです。<parameter>encoding</parameter> が省 略された場合、内部文字エンコーディングが使用されます。 </para> <para> <function>mb_internal_encoding</function>, <function>strlen</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-strpos"> <refnamediv> <refname>mb_strpos</refname> <refpurpose> 文字列の中に指定した文字列が最初に現れる位置を見つける </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>int <function>mb_strpos</function></funcdef> <paramdef>string <parameter>haystack</parameter></paramdef> <paramdef>string <parameter>needle</parameter></paramdef> <paramdef>int <parameter><optional>offset</optional></parameter> </paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_strpos</function> は、文字列 <parameter>haystack</parameter>の中で <parameter>needle</parameter>が最初に現れる位置を返します。 <parameter>needle</parameter> が見付からなかった場合、FALSEを返し ます。 </para> <para> <function>mb_strpos</function> にマルチバイト対応版の <function>strpos</function> 処理を文字数に基づき行います。 位置 <parameter>needle</parameter> は、 <parameter>haystack</parameter>の始めから数えられます。最初の文字 の位置は0、2番目の文字の位置は1、といったようになります。 </para> <para> <parameter>encoding</parameter> が省略された場合、内部文字エンコー ディングが使用されます。<function>strpos</function> が英字のみを 受けつけるのに対して、<function>mb_strpos</function> は、 <parameter>needle</parameter> に <literal>string</literal>を指定 可能です。 </para> <para> <parameter>offset</parameter> は検索オフセットです。指定されない 場合は、0 が使用されます。 </para> <para> <parameter>encoding</parameter> は文字エンコーディング名です。省 略された場合は、内部文字エンコーディングが使用されます。 </para> <para> <function>mb_strpos</function>, <function>mb_internal_encoding</function>, <function>strpos</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-strrpos"> <refnamediv> <refname>mb_strrpos</refname> <refpurpose> 文字列の中に指定した文字列が最後に現れる位置を見つける </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>int <function>mb_strrpos</function></funcdef> <paramdef>string <parameter>haystack</parameter></paramdef> <paramdef>string <parameter>needle</parameter></paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_strrpos</function> は、文字列 <parameter>haystack</parameter>の中で <parameter>needle</parameter>が最後に現れる位置を返します。 <parameter>needle</parameter> が見付からなかった場合、FALSEを返し ます。 </para> <para> <function>mb_strrpos</function> にマルチバイト対応版の <function>strrpos</function> 処理を文字数に基づき行います。 位置 <parameter>needle</parameter> は、 <parameter>haystack</parameter>の始めから数えられます。最初の文字 の位置は0、2番目の文字の位置は1、といったようになります。 </para> <para> <parameter>encoding</parameter> が省略された場合、内部文字エンコー ディングが使用されます。<function>strrpos</function> が英字のみを 受けつけるのに対して、<function>mb_strrpos</function> は、 <parameter>needle</parameter> に <literal>string</literal>を指定 可能です。 </para> <para> <parameter>offset</parameter> は検索オフセットです。指定されない 場合は、0 が使用されます。 </para> <para> <parameter>encoding</parameter> は文字エンコーディング名です。省 略された場合は、内部文字エンコーディングが使用されます。 </para> <para> <function>mb_strpos</function>, <function>mb_internal_encoding</function>, <function>strrpos</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-substr"> <refnamediv> <refname>mb_substr</refname> <refpurpose>文字列の一部を得る</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_substr</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>int <parameter>start</parameter></paramdef> <paramdef>int <parameter><optional>length</optional></parameter> </paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_substr</function> は、<parameter>start</parameter>お よび <parameter>length</parameter> パラメータで指定した <parameter>str</parameter>の一部を返します。 </para> <para> <function>mb_substr</function> は文字数に基づきマルチバイト対応の <function>substr</function>処理を行います。位置は、 <parameter>str</parameter>の始めから数えられます。最初の文字 の位置は0、2番目の文字の位置は1、といったようになります。 </para> <para> <parameter>encoding</parameter> は文字エンコーディング名です。省 略された場合は、内部文字エンコーディングが使用されます。 </para> <para> <function>mb_strcut</function>, <function>mb_internal_encoding</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-strcut"> <refnamediv> <refname>mb_strcut</refname> <refpurpose>文字列の一部を得る</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_strcut</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>int <parameter>start</parameter></paramdef> <paramdef>int <parameter><optional>length</optional></parameter> </paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_strcut</function> は、 <parameter>start</parameter> および <parameter>length</parameter> パラメータで指定した <parameter>str</parameter> の一部を返します。 </para> <para> <function>mb_strcut</function> は、<function>mb_substr</function> と同じ処理を異なった方法で行います。位置 <parameter>start</parameter> がマルチバイト文字の2バイト目以降で ある場合、マルチバイト文字の最初のバイトから開始されます。 </para> <para> この関数は、<parameter>length</parameter>より短く、かつマルチバイ ト文字列の一部でないかシフトシーケンスの中にない文字を取りだしま す。 </para> <para> <parameter>encoding</parameter> は文字エンコーディング名です。省 略された場合は、内部文字エンコーディングが使用されます。 </para> <para> <function>mb_substr</function>, <function>mb_internal_encoding</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-strwidth"> <refnamediv> <refname>mb_strwidth</refname> <refpurpose>文字列の幅を返す</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>int <function>mb_strwidth</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_strwidth</function> は文字列 <parameter>str</parameter>の幅を返します。 </para> <para> マルチバイト文字は通常シングルバイト文字の倍の幅となります。 </para> <para> <informalexample> <programlisting> 文字幅 U+0000 - U+0019 0 U+0020 - U+1FFF 1 U+2000 - U+FF60 2 U+FF61 - U+FF9F 1 U+FFA0 - 2 </programlisting> </informalexample> </para> <para> <parameter>encoding</parameter> は文字エンコーディングであり、省 略された場合は内部エンコーディングが使用されます。 </para> <para> <function>mb_strimwidth</function>, <function>mb_internal_encoding</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-strimwidth"> <refnamediv> <refname>mb_strimwidth</refname> <refpurpose>指定した幅で文字列を丸める</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_strmwidth</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>int <parameter>start</parameter></paramdef> <paramdef>int <parameter>width</parameter></paramdef> <paramdef>string <parameter>trimmarker</parameter></paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_strmwidth</function> は、文字列 <parameter>str</parameter>を指定した幅 <parameter>width</parameter>で丸めます。この関数は、丸められた文 字列を返します。 </para> <para> <parameter>trimmarker</parameter> が設定された場合、 <parameter>trimmarker</parameter> が丸められた文字列に追加されま す。 </para> <para> <parameter>start</parameter> は開始位置のオフセットであり、文字列 の始めからの文字数です。(最初の文字は0) </para> <para> <parameter>encoding</parameter> は文字エンコーディングであり、省 略された場合は内部エンコーディングが使用されます。 </para> <para> <example> <title><function>mb_strimwidth</function> の例</title> <programlisting role="php"> $str = mb_strimwidth($str, 0, 40, "..>"); </programlisting> </example> </para> <para> <function>mb_strwidth</function>, <function>mb_internal_encoding</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-convert-encoding"> <refnamediv> <refname>mb_convert_encoding</refname> <refpurpose>文字エンコーディングを変換する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_convert_encoding</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>string <parameter>to-encoding</parameter></paramdef> <paramdef>mixed <parameter><optional>from-encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_convert_encoding</function> は、文字列 <parameter>str</parameter>の文字エンコーディングを <parameter>from-encoding</parameter> から <parameter>to-encoding</parameter> に変換します。 </para> <para> <parameter>str</parameter> : 変換する文字列。 </para> <para> <parameter>from-encoding</parameter> により変換前の文字エンコーディ ング名が指定されます。これは、配列またはカンマ区切りの文字列とす ることが可能です。 </para> <para> <example> <title><function>mb_convert_encoding</function>の例</title> <programlisting role="php"> /* 内部文字エンコーディングからSJISに変換 */ $str = mb_convert_encoding($str, "SJIS"); /* EUC-JPからUTF-7に変換 */ $str = mb_convert_encoding($str, "UTF-7", "EUC-JP"); /* JIS, eucjp-win, sjis-winの順番で自動検出し、UCS-2LEに変換 */ $str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win"); /* "auto" は、"ASCII,JIS,UTF-8,EUC-JP,SJIS" に展開される */ $str = mb_convert_encoding($str, "EUC-JP", "auto"); </programlisting> </example> </para> <para> <function>mb_detect_order</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-detect-encoding"> <refnamediv> <refname>mb_detect_encoding</refname> <refpurpose>文字エンコーディングを検出する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_detect_encoding</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>mixed <parameter><optional>encoding-list</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_detect_encoding</function> は、文字列 <parameter>str</parameter>の文字エンコーディングを検出し、検出し た文字エンコーディングを返します。 </para> <para> <parameter>encoding-list</parameter> は文字エンコーディングのリス トで、エンコーディング検出の順番を配列またはカンマ区切りのリスト で指定します。 </para> <para> <parameter>encoding_list</parameter> が省略された場合、 detect_order が使用されます。 </para> <para> <example> <title><function>mb_detect_encoding</function> の例</title> <programlisting role="php"> /* カレントのdetect_orderで文字エンコーディングを検出 */ echo mb_detect_encoding($str); /* "auto" は "ASCII,JIS,UTF-8,EUC-JP,SJIS"に展開されます */ echo mb_detect_encoding($str, "auto"); /* カンマ区切りのリストで encoding_list 文字エンコーディングを指定 */ echo mb_detect_encoding($str, "JIS, eucjp-win, sjis-win"); /* encoding_list を指定するために配列を使用 */ $ary[] = "ASCII"; $ary[] = "JIS"; $ary[] = "EUC-JP"; echo mb_detect_encoding($str, $ary); </programlisting> </example> </para> <para> <function>mb_detect_order</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-convert-kana"> <refnamediv> <refname>mb_convert_kana</refname> <refpurpose> カナを("全角かな"、"半角かな"等に)変換する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_convert_kana</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>string <parameter>option</parameter></paramdef> <paramdef>mixed <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_convert_kana</function>は、文字列 <parameter>str</parameter>に関して「半角」-「全角」変換を行い、変 換された文字列を返します。この関数は、日本語のみで使用可能です。 </para> <para> <parameter>option</parameter> は変換オプションです。デフォルト値 は、<literal>"KV"</literal>です。 </para> <para> <parameter>encoding</parameter> は文字エンコーディングで、省略さ れた場合は内部文字エンコーディングが使用されます。 </para> <para> <informalexample> <programlisting> 使用可能な変換オプション オプション : 以下のオプションを変換時に指定します。デフォルトは "KV"です。 "r" : 「全角」英字を「半角」に変換 "R" : 「半角」英字を「全角」に変換 "n" : 「全角」数字を「半角」に変換 "N" : 「半角」数字を「全角」に変換 "a" : 「全角」英数字を「半角」に変換 "A" : 「半角」英数字を「全角」に変換 ("a", "A" オプションに含まれる文字は、U+0022, U+0027, U+005C, U+007Eを除く U+0021 - U+007E の範囲です) "s" : 「全角」スペースを「半角」に変換 (U+3000 -> U+0020) "S" : 「半角」スペースを「全角」に変換 (U+0020 -> U+3000) "k" : 「全角片仮名」を「半角片仮名」に変換 "K" : 「半角片仮名」を「全角片仮名」に変換 "h" : 「全角ひら仮名」を「半角片仮名」に変換 "H" : 「半角片仮名」を「全角ひら仮名」に変換 "c" : 「全角かた仮名」を「全角ひら仮名」に変換 "C" : 「全角ひら仮名」を「全角かた仮名」に変換 "V" : 濁点付きの文字を一文字に変換。"K","H"と共に使用します。 </programlisting> </informalexample> </para> <para> <example> <title><function>mb_convert_kana</function> の例</title> <programlisting role="php"> /* 「仮名」を全て「全角カタカナ」に変換します */ $str = mb_convert_kana($str, "KVC"); /* 「半角カタカナ」を「全角カタカナ」に変換し、「全角」英数字を「半角」 に変換します。 */ $str = mb_convert_kana($str, "KVa"); </programlisting> </example> </para> </refsect1> </refentry> <refentry id="function.mb-encode-mimeheader"> <refnamediv> <refname>mb_encode_mimeheader</refname> <refpurpose>MIMEヘッダの文字列をエンコードする</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_encode_mimeheader</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>string <parameter><optional>charset</optional></parameter> </paramdef> <paramdef>string <parameter><optional>transfer-encoding</optional></parameter> </paramdef> <paramdef>string <parameter><optional>linefeed</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_encode_mimeheader</function> は、文字列 <parameter>str</parameter> をヘッダフィールド用のエンコードに変換 します。この関数は、ASCIIエンコーディングされた文字列を返します。 </para> <para> <parameter>charset</parameter> は文字エンコーディング名です。デフォ ルトは、<literal>ISO-2022-JP</literal>です。 </para> <para> <parameter>transfer-encoding</parameter> は、transfer encoding で あり、 <literal>"B"</literal> (Base64) または <literal>"Q"</literal> (Quoted-Printable)のどちらかとする必要があ ります。デフォルトは、<literal>"B"</literal>です。 </para> <para> <parameter>linefeed</parameter> は行末のマーカです。デフォルトは、 <literal>"\r\n"</literal> (CRLF)です。 </para> <para> <example> <title><function>mb_convert_kana</function> の例</title> <programlisting role="php"> $name = "太郎"; // 漢字 $mbox = "kru"; $doma = "gtinn.mon"; $addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">"; echo $addr; </programlisting> </example> </para> <para> <function>mb_decode_mimeheader</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-decode-mimeheader"> <refnamediv> <refname>mb_decode_mimeheader</refname> <refpurpose>MIMEヘッダフィールドの文字列をデコードする</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_decode_mimeheader</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_decode_mimeheader</function> は、エンコードされた MIMEヘッダの文字列<parameter>str</parameter>をデコードします。 </para> <para> この関数は、内部文字エンコーディングでデコードされた文字列を返し ます。 </para> <para> <function>mb_encode_mimeheader</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-convert-variables"> <refnamediv> <refname>mb_convert_variables</refname> <refpurpose>変数の文字コードを変換する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_convert_variables</function></funcdef> <paramdef>string <parameter>to-encoding</parameter></paramdef> <paramdef>mixed <parameter>from-encoding</parameter></paramdef> <paramdef>mixed <parameter>vars</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_convert_variables</function> は、エンコーディング <parameter>from-encoding</parameter>の変数 <parameter>vars</parameter>をエンコーディング <parameter>to-encoding</parameter>に変換します。成功時に変換ド前 の文字エンコーディングを返し、失敗した場合にFALSEを返します。 </para> <para> <function>mb_convert_variables</function> は、エンコーディング検 出のためにArrayまたはObjectの文字列を結合します。これは、エンコー ディング検出は短い文字列では失敗する傾向があるためです。このため、 1つの配列またはオブジェクトにエンコーディングを混ぜることはできま せん。 </para> <para> <parameter>from-encoding</parameter> に配列またはカンマ区切り の文字列が指定された場合、<parameter>from-coding</parameter>から エンコーディングの検出を試みます。<parameter>encoding</parameter> が省略された場合、<literal>detect_order</literal> が使用されます。 </para> <para> <parameter>vars</parameter>(3番目以降の引数)は、変換する変数への リファレンスです。文字列、配列、オブジェクトを指定することが可能 です。<function>mb_convert_variables</function> は全てのパラメー タが同じエンコーディングを有することを仮定します。 </para> <para> <example> <title><function>mb_convert_variables</function> の例</title> <programlisting role="php"> /* 変数 $post1, $post2 を内部エンコーディングに変換する */ $interenc = mb_internal_encoding(); $inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $post2); </programlisting> </example> </para> </refsect1> </refentry> <refentry id="function.mb-encode-numericentity"> <refnamediv> <refname>mb_encode_numericentity</refname> <refpurpose> 文字をHTML数値エンティティにエンコードする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_encode_numericentity</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>array <parameter>convmap</parameter></paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_encode_numericentity</function> は、 <parameter>str</parameter>の中で指定した文字コードをHTML数値エン ティティから文字コードに変換します。この関数は変換後も文字列を返 します。 </para> <para> <parameter>array</parameter> は、変換するコード領域を指定する配列 です。 </para> <para> <parameter>encoding</parameter> は文字エンコーディングです。 </para> <para> <example> <title><parameter>convmap</parameter> の例</title> <programlisting role="php"> $convmap = array ( int start_code1, int end_code1, int offset1, int mask1, int start_code2, int end_code2, int offset2, int mask2, ........ int start_codeN, int end_codeN, int offsetN, int maskN ); // start_codeN および end_codeN に Unicode値を指定 // 値にoffsetNを追加、マスクmaskNを指定してビット毎の'AND'をとり、 // 数値エンティティに値を変換します。 </programlisting> </example> </para> <para> <example> <title> <function>mb_encode_numericentity</function> の例 </title> <programlisting role="php"> /* ISO-8859-1の左面をHTML数値エンティティに変換 */ $convmap = array(0x80, 0xff, 0, 0xff); $str = mb_encode_numericentity($str, $convmap, "ISO-8859-1"); /* ブロック 95-104 にあるSJIS-winコードのユーザ定義領域を数値エンティ ティに変換 */ $convmap = array( 0xe000, 0xe03e, 0x1040, 0xffff, 0xe03f, 0xe0bb, 0x1041, 0xffff, 0xe0bc, 0xe0fa, 0x1084, 0xffff, 0xe0fb, 0xe177, 0x1085, 0xffff, 0xe178, 0xe1b6, 0x10c8, 0xffff, 0xe1b7, 0xe233, 0x10c9, 0xffff, 0xe234, 0xe272, 0x110c, 0xffff, 0xe273, 0xe2ef, 0x110d, 0xffff, 0xe2f0, 0xe32e, 0x1150, 0xffff, 0xe32f, 0xe3ab, 0x1151, 0xffff ); $str = mb_encode_numericentity($str, $convmap, "sjis-win"); </programlisting> </example> </para> <para> <function>mb_decode_numericentity</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb_decode_numericentity"> <refnamediv> <refname>mb_decode_numericentity</refname> <refpurpose> HTML数値エンティティを文字にデコードする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>mb_decode_numericentity</function></funcdef> <paramdef>string <parameter>str</parameter></paramdef> <paramdef>array <parameter>convmap</parameter></paramdef> <paramdef>string <parameter><optional>encoding</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> 文字列<parameter>str</parameter>において指定した文字領域にある数 値エンティティを変換し、変換後の文字列を返します。 </para> <para> <parameter>array</parameter> は変換するコード領域を指定する配列で す。 </para> <para> <parameter>encoding</parameter> は文字エンコーディングで、省略さ れた場合は内部文字エンコーディングが使用されます。 </para> <para> <example> <title><parameter>convmap</parameter> の例</title> <programlisting> $convmap = array ( int start_code1, int end_code1, int offset1, int mask1, int start_code2, int end_code2, int offset2, int mask2, ........ int start_codeN, int end_codeN, int offsetN, int maskN ); // start_codeN および end_codeN に Unicode値を指定 // 値にoffsetNを追加、マスクmaskNを指定してビット毎の'AND'をとり、 // 数値エンティティに値を変換します。 </programlisting> </example> </para> <para> <function>mb_encode_numericentity</function>も参照下さい。 </para> </refsect1> </refentry> <refentry id="function.mb-send-mail"> <refnamediv> <refname>mb_send_mail</refname> <refpurpose> エンコード変換を行ってメールを送信する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>boolean <function>mb_send_mail</function></funcdef> <paramdef>string <parameter>to</parameter></paramdef> <paramdef>string <parameter>subject</parameter></paramdef> <paramdef>string <parameter>message</parameter></paramdef> <paramdef>string <parameter><optional>additional_headers</optional></parameter> </paramdef> <paramdef>string <parameter><optional>additional_parameter</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>mb_send_mail</function> は、emailを送信します。ヘッダと メッセージは<function>mb_language</function>の設定に基づき変換、 エンコードされます。<function>mb_send_mail</function> は、 <function>mail</function>のラッパー関数です。詳細は、 <function>mail</function> を参照下さい。 </para> <para> <parameter>to</parameter> は送信先のメールアドレスです。各アドレ スをカンマで区切ることにより複数の宛先を指定可能です。 </para> <para> <parameter>subject</parameter> はメールの題名です。 </para> <para> <parameter>message</parameter> はメールのメッセージです。 </para> <para> <parameter>additional_headers</parameter> は、ヘッダの最後に挿入 されます。これは、通常、ヘッダを追加する際に使用されます。 改行(\n)で区切ることにより複数のヘッダを指定可能です。 </para> <para> <parameter>additional_parameter</parameter> は、MTA のコマンドラ インパラメータです。sendmailを使用する場合に正しいReturn-Pathを設 定する場合に便利です。 </para> <para> 成功時に<literal>TRUE</literal>、その他の場合 <literal>FALSE</literal>を返します。 </para> <para> <function>mb_language</function>, <function>mail</function>も参照下さい。 </para> </refsect1> </refentry> </reference> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: --> <!-- Keep this comment for vi/vim/gvim vi: et:ts=1:sw=1 -->
« previous php.doc (#969335586) next »