Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utf-8 read incorrect #58

Closed
diida opened this issue Mar 1, 2016 · 1 comment
Closed

utf-8 read incorrect #58

diida opened this issue Mar 1, 2016 · 1 comment

Comments

@diida
Copy link

diida commented Mar 1, 2016

I converts MaxMind CSV files to .dat files use
https://github.com/mteodoro/mmutils/blob/master/csv2dat.py
And translate some city name to local language(Fuzhou=> Fuzhou福州)before convert.

# encoding: UTF-8
require "geoip"
@database="mmcity.dat"
geoip_initialize = ::GeoIP.new(@database)
info=geoip_initialize.city("218.85.*.*")
print info.city_name

# output Fuzhouç¦�å·

I modify some code in "geoip.rb"
line 781

# city = city.force_encoding('iso-8859-1').encode('utf-8') if city.respond_to?(:force_encoding)
city.force_encoding(Encoding::UTF_8) # add this just for [logstash geoip filter ](https://github.com/logstash-plugins/logstash-filter-geoip/blob/master/lib/logstash/filters/geoip.rb) line 192

#output:Fuzhou福州

Test on jruby 1.9 in logstash and ruby 2.0.0

@cjheath
Copy link
Owner

cjheath commented Mar 2, 2016

The CSV files and the GeoIP database are not UTF-8. They are in fact Latin-1 (ISO-8859-1), which is what my code enforces.

You have added UTF-8, so you have produced a non-standard GeoIP database file, and you need your non-standard code to read it correctly.

@cjheath cjheath closed this as completed Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants