• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H15-May-2016-863622

t/H15-May-2016-532445

util/H15-May-2016-176117

.gitignoreH A D15-May-2016597 6362

README.markdownH A D15-May-20165.1 KiB198135

configH A D03-May-20223.3 KiB117103

valgrind.suppressH A D15-May-20162.6 KiB167166

README.markdown

1<!---
2Don't edit this file manually! Instead you should generate it by using:
3    wiki2markdown.pl doc/manpage.wiki
4-->
5
6Name
7====
8
9iconv-nginx-module
10
11Table of Contents
12=================
13
14* [Name](#name)
15* [Description](#description)
16* [Usage](#usage)
17    * [set_iconv](#set_iconv)
18    * [iconv_buffer_size](#iconv_buffer_size)
19    * [iconv_filter](#iconv_filter)
20* [Compatibility](#compatibility)
21* [Installation](#installation)
22    * [Building as a dynamic module](#building-as-a-dynamic-module)
23* [Copyright & License](#copyright--license)
24* [Changelog](#changelog)
25* [See Also](#see-also)
26
27Description
28===========
29
30This is a nginx module that uses libiconv to convert characters of different
31encoding. It brings the 'set_iconv' command to nginx.
32
33This module depends on the ngx_devel_kit(NDK) module.
34
35Usage
36=====
37
38set_iconv
39---------
40
41**syntax:** *set_iconv &lt;destination_variable&gt; &lt;from_variable&gt; from=&lt;from_encoding&gt; to=&lt;to_encoding&gt;*
42
43**default:** *none*
44
45**phase:** *rewrite*
46
47[Back to TOC](#table-of-contents)
48
49iconv_buffer_size
50-----------------
51
52**syntax:** *iconv_buffer_size &lt;size&gt;*
53
54**default:** *iconv_buffer_size &lt;pagesize&gt;*
55
56[Back to TOC](#table-of-contents)
57
58iconv_filter
59------------
60
61**syntax:** *iconv_filter from=&lt;from_encoding&gt; to=&lt;to_encoding&gt;*
62
63**default:** *none*
64
65**phase:** *output-filter*
66
67Here is a basic example:
68
69```nginx
70
71 #nginx.conf
72
73 location /foo {
74     set $src '你好'; #in UTF-8
75     set_iconv $dst $src from=utf8 to=gbk; #now $dst holds 你好 in GBK
76 }
77
78 #everything generated from /foo will be converted from utf8 to gbk
79 location /bar {
80     iconv_filter from=utf-8 to=gbk;
81     iconv_buffer_size 1k;
82     #content handler here
83 }
84```
85
86[Back to TOC](#table-of-contents)
87
88Compatibility
89=============
90
91The following versions of Nginx should work with this module:
92
93* 1.9.x (last tested: 1.9.15)
94* 1.8.x
95* 1.7.x
96* 1.6.x
97* 1.5.x
98* 1.4.x
99* 1.3.x
100* 1.2.x (last tested: 1.2.7)
101* 1.1.x (last tested: 1.1.5)
102* 1.0.x (last tested: 1.0.8)
103* 0.9.x (last tested: 0.9.4)
104* 0.8.x (last tested: 0.8.54)
105* 0.7.x (last tested: 0.7.68)
106
107[Back to TOC](#table-of-contents)
108
109Installation
110============
111
112Get the nginx source code from [nginx.org](http://nginx.org/).
113Untar the source code and build nginx with this module.
114
115```bash
116
117 wget 'http://sysoev.ru/nginx/nginx-1.9.15.tar.gz'
118 tar -xzvf nginx-1.9.15.tar.gz
119 cd nginx-1.9.15/
120
121 git-clone http://github.com/simpl-it/ngx_devel_kit.git
122 git-clone http://github.com/calio/form-input-module.git
123
124 ./configure --add-module=/path/to/iconv-nginx-module/ --add-module=/path/to/ngx_devel_kit
125 make -j2
126 make install
127```
128
129[Back to TOC](#table-of-contents)
130
131Building as a dynamic module
132----------------------------
133
134Starting from NGINX 1.9.11, you can also compile this module as a dynamic module, by using the `--add-dynamic-module=PATH` option instead of `--add-module=PATH` on the
135`./configure` command line above. And then you can explicitly load the module in your `nginx.conf` via the [load_module](http://nginx.org/en/docs/ngx_core_module.html#load_module)
136directive, for example,
137
138```nginx
139load_module /path/to/modules/ndk_http_module.so;  # assuming NDK is built as a dynamic module too
140load_module /path/to/modules/ngx_http_iconv_module.so;
141```
142
143[Back to TOC](#table-of-contents)
144
145Copyright & License
146===================
147
148This program is licenced under the BSD license.
149
150Copyright (c) 2010-2016, Calio <vipcalio@gmail.com>.
151
152Copyright (c) 2010-2016, Yichun Zhang <agentzh@gmail.com>.
153
154All rights reserved.
155
156Redistribution and use in source and binary forms, with or without
157modification, are permitted provided that the following conditions
158are met:
159
160* Redistributions of source code must retain the above copyright
161notice, this list of conditions and the following disclaimer.
162* Redistributions in binary form must reproduce the above copyright
163notice, this list of conditions and the following disclaimer in the
164documentation and/or other materials provided with the distribution.
165* Neither the name of the Taobao Inc. nor the names of its
166contributors may be used to endorse or promote products derived from
167this software without specific prior written permission.
168
169THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
170"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
172A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
173HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
174SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
175TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
176PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
177LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
178NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
179SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
180
181[Back to TOC](#table-of-contents)
182
183Changelog
184=========
185
186This module's change logs are part of the OpenResty bundle's change logs. Please see
187See <http://openresty.org/#Changes>
188
189[Back to TOC](#table-of-contents)
190
191See Also
192========
193
194* The [OpenResty](https://openresty.org) bundle.
195
196[Back to TOC](#table-of-contents)
197
198