raspell icon indicating copy to clipboard operation
raspell copied to clipboard

raspell dosn't return valid encodings (ruby 1.9)

Open ctrochalakis opened this issue 14 years ago • 2 comments

raspell suggest method returns asci-8bit strings instead of the correct encoding that was requested.

# -*- encoding : utf-8 -*-
require 'raspell'

w = "πράσυνο"
as = Aspell.new('el_GR', nil, nil, 'utf-8')
res = as.suggest(w)
p res
p res.first.encoding

Prints:

["\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xBF", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCF\x8C", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xBF\xCF\x82", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xBF\xCF\x85", "\xCF\x80\xCF\x81\xCE\xB1\xCF\x83\xCE\xAF\xCE\xBD\xCE\xBF\xCF\x85", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xBF\xCE\xB9", "\xCE\xA0\xCF\x81\xCE\xB1\xCF\x84\xCE\xAF\xCE\xBD\xCE\xBF", "\xCE\xB8\xCF\x81\xCE\xB1\xCF\x83\xCF\x8D\xCE\xBD\xCF\x89", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xB1", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xB5", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCE\xB7", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xBF\xCE\xBD", "\xCF\x80\xCF\x81\xCE\xB1\xCF\x83\xCE\xB9\xCF\x8E\xCE\xBD", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xBF", "\xCF\x80\xCF\x81\xCE\xAC\xCF\x83\xCE\xB9\xCE\xBD\xCF\x89\xCE\xBD", "\xCF\x80\xCF\x81\xCE\xB1\xCF\x83\xCE\xAF\xCE\xBD\xCF\x89\xCE\xBD", "\xCF\x80\xCF\x81\xCE\xB1\xCE\xB0\xCE\xBD\xCF\x89"]
#<Encoding:ASCII-8BIT>

ctrochalakis avatar Jan 02 '12 14:01 ctrochalakis

I don't personally use Raspell anymore so mostly I curate pull requests...patches welcome, if you can figure it out.

evan avatar Jan 02 '12 19:01 evan

Fair enough. As a quick fix, I force encode the results to utf-8.

I 'll see if I can write a patch for it.

ctrochalakis avatar Jan 03 '12 07:01 ctrochalakis