Version about spring-boot 2.5.1. Do I have a problem learning how to use webFlux: I use Flux.fromStream() to get datas, datas garbled. I try to set produces = "text/event-stream;charset=UTF-8", but useless. My code on this pictures: Spring Use flux to response garbled code

Comment From: snicoll

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

Comment From: free-leung

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

Ok, Thanks.

Comment From: rong-zhi-yi

The problem here is that Spring uses the to convert the into the http response body. This converter defaults to the charset, even though is required by specification when you use StringHttpMessageConverterFluxISO-8859-1UTF-8produces = "text/event-stream" in org/springframework/http/converter/StringHttpMessageConverter.java:51

 ...
 public static final Charset DEFAULT_CHARSET = StandardCharsets.ISO_8859_1;
 ...

You can do this:

@Configuration public class WebConfig implements WebMvcConfigurer {

@Override public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { converters.stream() .filter(converter -> converter instanceof StringHttpMessageConverter) .forEach(converter -> ((StringHttpMessageConverter) converter) .setDefaultCharset(StandardCharsets.UTF_8)); } }