Denis F. Latypoff
January 27, 2011 05:20AM
Hello, by default GeoIP returns ISO-8859-1 encoded city names which
is not suitable sometimes (e.g varchar utf8 in the DB may cause broken
names, etc). So attached patch allows to use UTF-8 in city names.

--
br, Denis F. Latypoff.diff -ru nginx-0.9.3/src/http/modules/ngx_http_geoip_module.c nginx-0.9.3.GeoIP-utf8/src/http/modules/ngx_http_geoip_module.c
--- nginx-0.9.3/src/http/modules/ngx_http_geoip_module.c 2010-08-03 13:38:08.000000000 -0500
+++ nginx-0.9.3.GeoIP-utf8/src/http/modules/ngx_http_geoip_module.c 2011-01-27 04:06:09.000000000 -0600
@@ -50,14 +50,14 @@
static ngx_command_t ngx_http_geoip_commands[] = {

{ ngx_string("geoip_country"),
- NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+ NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE12,
ngx_http_geoip_country,
NGX_HTTP_MAIN_CONF_OFFSET,
0,
NULL },

{ ngx_string("geoip_city"),
- NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+ NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE12,
ngx_http_geoip_city,
NGX_HTTP_MAIN_CONF_OFFSET,
0,
@@ -446,6 +446,20 @@
return NGX_CONF_ERROR;
}

+ if (cf->args->nelts == 3) {
+
+ if (ngx_strcmp(value[2].data, "utf8") == 0) {
+
+ GeoIP_set_charset (gcf->country, GEOIP_CHARSET_UTF8);
+
+ } else {
+
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid parameter \"%V\"", &value[2]);
+ return NGX_CONF_ERROR;
+ }
+ }
+
switch (gcf->country->databaseType) {

case GEOIP_COUNTRY_EDITION:
@@ -485,6 +499,20 @@
return NGX_CONF_ERROR;
}

+ if (cf->args->nelts == 3) {
+
+ if (ngx_strcmp(value[2].data, "utf8") == 0) {
+
+ GeoIP_set_charset (gcf->city, GEOIP_CHARSET_UTF8);
+
+ } else {
+
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid parameter \"%V\"", &value[2]);
+ return NGX_CONF_ERROR;
+ }
+ }
+
switch (gcf->city->databaseType) {

case GEOIP_CITY_EDITION_REV0:
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] GeoIP module: UTF-8 support in city names

Denis F. Latypoff 4017 January 27, 2011 05:20AM

Re: [PATCH] GeoIP module: UTF-8 support in city names

Igor Sysoev 1168 January 27, 2011 05:28AM

Re: [PATCH] GeoIP module: UTF-8 support in city names

Denis F. Latypoff 1083 January 27, 2011 05:34AM

Re: [PATCH] GeoIP module: UTF-8 support in city names

Igor Sysoev 1201 January 27, 2011 05:38AM

Re: [PATCH] GeoIP module: UTF-8 support in city names

Denis F. Latypoff 1017 January 27, 2011 05:44AM

Re: [PATCH] GeoIP module: UTF-8 support in city names

Igor Sysoev 1439 January 27, 2011 05:50AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 286
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready