Skip to content

Setting default charset in StringHttpMessageConverter [SPR-7904] #12559

Closed

Description

@spring-projects-issues

Thomas Ziem opened SPR-7904 and commented

Currently, StringHttpMessageConverter uses ISO-8859-1 as default charset for reading and writing:

public static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
protected String readInternal(Class clazz, HttpInputMessage inputMessage) throws IOException {
    MediaType contentType = inputMessage.getHeaders().getContentType();
    Charset charset = contentType.getCharSet() != null ? contentType.getCharSet() : DEFAULT_CHARSET;
    return FileCopyUtils.copyToString(new InputStreamReader(inputMessage.getBody(), charset));
}

It would be nice if it could be configured from outside.


Affects: 3.0.5

Issue Links:

Backported to: 3.1.2

3 votes, 1 watchers

Activity

  1. spring-projects-issues commented on Jan 28, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    I think SPR-7504 will help.

  2. spring-projects-issues commented on Apr 1, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Srđan Šrepfler commented

    Please take into account this is used by spring integration as well so there should be a way to configure this which is not bound to the mvc framework.

  3. added
    status: backported
    type: enhancement
    status: duplicate
    in: web
    on Jan 11, 2019
  4. added this to the 3.2 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webstatus: backportedstatus: duplicatetype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions