I used win-redis-server-2.6 to store some simple key-value pairs, redis-cli.exe to set in key-values, and then get the value out through Jedis.
First, redis-cli > set foo "中" the responde is ok
Then, Using Jedis
JedisPoolConfig poolConfig = new JedisPoolConfig();
jPool = new JedisPool(poolConfig, host, port);
Jedis jedis = jPool.getResource();
String test= jedis.get("foo");
System.out.println(test);
BUT, i got this �� I have searched the problem, but i got no help.
Redis - problem with accents (UTF-8 encoding) How to save and retrieve string with accents in redis?
these two ways can not solve my problem, because i must use the jedis to get out the value.
I have tried redis-cli --raw get foo this can get out the value, but when i remove the --raw option , the redis-cli.exe just crashed.
And for set values i have tried using hiredis-C-client to set value, but also i got the problem.
BUT when i set value through Jedis and get value also using Jedis ,It is OK.
Also i have tried to decode the value get out by jedis,using the following code String newStr = new String(test.getBytes("UTF-8"), "UTF-8"); I have tried "GBK", "GB2312", "ISO-8859-1" , but all failed.
Could anyone please help me? Thanks in advance.
Kong