开发者

jedis or redis trouble with encoding ISO-8859-5

开发者 https://www.devze.com 2023-03-27 05:07 出处:网络
I test redis and jedis API for encoding ISO-8859-5: String S = new String(\"Привет мир\".getBytes(), \"ISO-8859-5\");

I test redis and jedis API for encoding ISO-8859-5:

        String S = new String("Привет мир".getBytes(), "ISO-8859-5");
    redis.lpush("test", S);
    System.out.println(redis.lpop("test"));

In result, I have: а�б�аИаВаЕб� аМаИб�

Then I try to use SafeEncoder:

        String S = new String("Привет мир".getBytes(), "ISO-8859-5");
    redis.lpush("test", S);
    byte[] Result = SafeEncoder.encode(redis.lpop("test"));
    System.out.println(new String(Result));

Result: аАТаБТаАааАааАааБТ аАааАааБТ

What I do wrong开发者_运维百科? Is it me or redis, or jedis?


You can use the binary form directly

byte[] b = "Привет мир".getBytes();
redis.lpush(SafeEncoder.encode("test"), b);
System.out.println(redis.lpop("test"));


Try convert information to UTF-8.
by the way, if you have problems with cyrrilic encoding , this site may help you ( 2cyr.com )

0

精彩评论

暂无评论...
验证码 换一张
取 消