diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py
index 3eae261..8d78386 100644
a
|
b
|
class GeoIPRecord(Structure):
|
23 | 23 | ('continent_code', c_char_p), |
24 | 24 | ] |
25 | 25 | geoip_char_fields = [name for name, ctype in GeoIPRecord._fields_ if ctype is c_char_p] |
| 26 | GEOIP_DEFAULT_ENCODING = 'iso-8859-1' |
26 | 27 | geoip_encodings = { |
27 | 28 | 0: 'iso-8859-1', |
28 | 29 | 1: 'utf8', |
… |
… |
def check_string(result, func, cargs):
|
100 | 101 | free(result) |
101 | 102 | else: |
102 | 103 | s = '' |
103 | | return s.decode() |
| 104 | return s.decode(GEOIP_DEFAULT_ENCODING) |
104 | 105 | |
105 | 106 | GeoIP_database_info = lgeoip.GeoIP_database_info |
106 | 107 | GeoIP_database_info.restype = geoip_char_p |
… |
… |
GeoIP_database_info.errcheck = check_string
|
111 | 112 | def string_output(func): |
112 | 113 | def _err_check(result, func, cargs): |
113 | 114 | if result: |
114 | | return result.decode() |
| 115 | return result.decode(GEOIP_DEFAULT_ENCODING) |
115 | 116 | return result |
116 | 117 | func.restype = c_char_p |
117 | 118 | func.errcheck = _err_check |
diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py
index 8d7bdff..9631a19 100644
a
|
b
|
class GeoIPTest(unittest.TestCase):
|
119 | 119 | g = GeoIP() |
120 | 120 | d = g.city("www.osnabrueck.de") |
121 | 121 | self.assertEqual('Osnabrück', d['city']) |
| 122 | d = g.country('200.7.49.81') |
| 123 | self.assertEqual('Curaçao', d['country_name']) |