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

Code assumes UTF-8 encoding #7

Closed
tepperly opened this issue May 30, 2015 · 0 comments
Closed

Code assumes UTF-8 encoding #7

tepperly opened this issue May 30, 2015 · 0 comments

Comments

@tepperly
Copy link
Contributor

The C code assumes that the arguments are in UTF-8 encoding.

$ irb
irb(main):001:0> a = "\xe8".force_encoding("iso8859-1")
=> "\xE8"
irb(main):002:0> b = a.encode("utf-8")
=> "è"
irb(main):003:0> JaroWinkler.distance(a, b)
NameError: uninitialized constant JaroWinkler
        from (irb):3
        from /usr/local/bin/irb:11:in `<main>'
irb(main):004:0> require 'jaro_winkler'
=> true
irb(main):005:0> JaroWinkler.distance(a, b)
=> 0.0
irb(main):006:0> a.encoding
=> #<Encoding:ISO-8859-1>
irb(main):007:0> b.encoding
=> #<Encoding:UTF-8>
irb(main):008:0> 
tonytonyjan added a commit that referenced this issue Sep 30, 2017
Do not treat every string as UTF-8 encoding, instead, use Ruby's API to get unicode codepoints.

close #7
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

1 participant