Question

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?

Était-ce utile?

La solution

You can use the binary form directly

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top