2

I am trying to store portugese word 'como você está' for a key in redis. Value is set in redis in unicode format 'como voc\x88 est\xa0184\' in redis. But while fetching the value through StringRedisTemplate in Java am getting weird values like 'como voc� est�184'. I tried the code below, but it is not working.

template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(new StringRedisSerializer());

Here template object is of StringRedisTemplate class. Is there any mechanism to get the special characters back?

1
  • Not sure if your claim is correct. The value you have shown in question should be printed on console/file that does not support UTF-8. Commented Apr 21, 2021 at 15:38

1 Answer 1

1

Try putting this in your application.properties file:

spring.http.encoding.charset=UTF-8 # the encoding of HTTP requests/responses
spring.http.encoding.enabled=true # enable http encoding support
spring.http.encoding.force=true # force the configured encoding
Sign up to request clarification or add additional context in comments.

1 Comment

It will not work as data is coming wrong while fetching from redis directly. its not a spring boot thing. I tried, its not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.