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

when use japanese or chinese in bin value get error: incompatible character encodings: ASCII-8BIT and UTF-8 #33

Closed
fs-wu opened this issue Feb 3, 2016 · 3 comments
Assignees
Labels

Comments

@fs-wu
Copy link

fs-wu commented Feb 3, 2016

When I set japanese in bin value, I got such kind error:
" incompatible character encodings: ASCII-8BIT and UTF-8"
How can I avoid that?

Here my easy code:

# -*- coding: utf-8 -*-
require 'rubygems'
require 'aerospike'
include Aerospike

client = Client.new('127.0.0.1', 3000)
key = Key.new('test', 'test', 'key1')
bin1 = Bin.new('bin1','あああ')

client.put(key,[bin1])

client.close
@jhecking jhecking closed this as completed Feb 3, 2016
@jhecking jhecking added the bug label Feb 3, 2016
@jhecking jhecking self-assigned this Feb 3, 2016
@jhecking
Copy link
Contributor

jhecking commented Feb 3, 2016

@fs-wu, thanks for reporting this issue. The Aerospike server stores strings as binary strings, i.e. not bound to any specific encoding. But the Ruby client should assume UTF-8 as the default encoding and convert all string to/from binary encoding automatically.

I have committed a fix to master in 6ef31a8. I am planning to do a minor bug fix release for the aerospike package next week. But if you want, you can build the package yourself from master branch and give it a try.

@fs-wu
Copy link
Author

fs-wu commented Feb 3, 2016

Thank you,it worked.Wait for your new gem version.

@jhecking
Copy link
Contributor

@fs-wu, v1.0.12 of the gem is now available on rubygems.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants