Iconv¶
説明¶
iconv-nginx-module - libiconvを異なるエンコーディングの文字を変換するために使用します。set_iconv
コマンドをNGINに渡します。
このモジュールはngx_devel_kit (NDK)モジュールに依存します。
インストール
- NGINXソースコードをhttp://nginx.orgから取得します。
- ソースコードを解凍しこのモジュールを使ってNGINXをビルドします。
$ wget 'http://sysoev.ru/nginx/nginx-0.8.28.tar.gz'
$ tar -xzvf nginx-0.8.28.tar.gz
$ cd nginx-0.8.28/
$ git-clone http://github.com/simpl-it/ngx_devel_kit.git
$ git-clone http://github.com/calio/form-input-module.git
$ ./configure --add-module=/somepath/iconv-nginx-module/ --add-module=/somepath/ngx_devel_kit
$ make -j2
$ make install
使い方
set_iconv¶
構文: | set_iconv <destination_variable> <from_variable> from=<from_encoding> to=<to_encoding> |
---|---|
デフォルト: | none |
iconv_buffer_size¶
構文: | iconv_buffer_size <size> |
---|---|
デフォルト: | ngx_pagesize |
iconv_filter¶
構文: | iconv_filter from=<from_encoding> to=<to_encoding> |
---|---|
デフォルト: | none |
以下は基本的な例です:
#nginx.conf
location /foo {
set $src '你好'; #in UTF-8
set_iconv $dst $src from=utf8 to=gbk; #now $dst holds 你好 in GBK
}
#everything generated from /foo will be converted from utf8 to gbk
location /bar {
iconv_filter from=utf-8 to=gbk;
iconv_buffer_size 1k;
#content handler here
}
Copyright & License¶
このプログラムはBSDライセンスのもとにライセンスされます。
Copyright (c) 2010, Taobao Inc, Alibaba Group ( http://www.taobao.com/market/global/index_new.php ). Copyright (c) 2010, Calio <vipcalio@gmail.com>.
無断転載禁ず
修正の如何に関係なくソースおよびバイナリ形式での再配布および使用は以下の条件に合う限り許可されます:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the Taobao Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
変更ログ¶
- v0.02 -
iconv_filter
とiconv_buffer_size
の説明を追加しました。 - v0.01 -
set_iconv
説明を実装しました。