Search code examples
goutf-8aerospike

Aerospike charset utf8 setting


I am inserting a record in aerospike. Everything is working fine on my local environment. However, on the staging environment, UTF-8 characters are not being stored correctly.

aql> select msg from test.msges

LIST('["{"message_id":"kxwFZHVBKj","title":"คำถามได้รับà¸à¸²à¸£à¸•à¸­à¸šà¸à¸¥à¸±à¸šà¹à¸¥à¹‰à¸§!","actions": | +----------------------------------------------------------------------------------------------------------+ 1 row in set (0.038 secs)

Also, this is being done using a golang clinet which is pretty UTF-8 safe i.e. no problems of byte-to-string or string-to-byte conversions and this works fine on local, hence I am assuming this has something to do with aerospike configuration or version. The aerospike version on my local is 3.14.1.1 and on staging is 3.9.1.1.

One more thing I noticed based on the c-client comments coming on this post is that on my local machine I get the following aql version:

Aerospike Query Client Version 3.13.0.1 C Client Version 4.1.6

But on the remote I have the following:

Aerospike Query Client Version 3.9.1.2

The C-client version is missing !

Anyone can help what configuration (or whatever) am I missing here ?


Solution

  • aql is a tool written in c-client. In c-client, the application is expected to handle utf-8 encoding as there is no "string" datatype similar to newer generation languages that support multibyte utf-8 characters. The application reading data should have prior knowledge that the data is indeed written with utf-8 encoding to handle that. aql cannot determine that as it is a generic tool. So, it ends up printing each byte as a character.