Skip to content

spring-boot hello world is not unicode friendly #1800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stepancheg opened this issue Oct 31, 2014 · 4 comments
Closed

spring-boot hello world is not unicode friendly #1800

stepancheg opened this issue Oct 31, 2014 · 4 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@stepancheg
Copy link

Take hello world application from spring-boot main page:

package hello;

import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@Controller
@EnableAutoConfiguration
public class SampleController {

    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, args);
    }
}

Replace Hello world! with Много букв!, and you get a lot of question marks instead of greeting. Using spring-boot 1.1.8.RELEASE.

@dsyer
Copy link
Member

dsyer commented Nov 1, 2014

Duplicate of #1182?

@snicoll
Copy link
Member

snicoll commented Nov 1, 2014

#1182 is for the URI, not the body. @stepancheg we auto-configure the embedded containers to use UTF-8. How are you deploying this hello world app? Using spring-boot-starter-web?

@snicoll snicoll self-assigned this Nov 1, 2014
@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Nov 3, 2014
@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Nov 4, 2014
@snicoll
Copy link
Member

snicoll commented Nov 4, 2014

Interestingly enough, I can reproduce and adding the CharacterEncodingFilter does not change anything, the reply is still ISO-8859-1

curl -i http://localhost:8080
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 11
Date: Tue, 04 Nov 2014 09:18:04 GMT

The reason why (thanks @bclozel !) is in StringHttpMessageConverter: it does not get a Charset in the provided MediaType so it just uses the default. I have no idea why we don't look for the charSet of the response (and if we should).

@snicoll snicoll added the type: enhancement A general enhancement label Nov 4, 2014
@snicoll
Copy link
Member

snicoll commented Nov 4, 2014

It looks like that configuring that converter to use UTF-8 by default (like Jackson does) is the best option.

@snicoll snicoll closed this as completed in cbd3c39 Nov 4, 2014
@snicoll snicoll added this to the 1.2.0.RC1 milestone Nov 4, 2014
bclozel added a commit that referenced this issue Jan 16, 2015
This commit prevents the `Accept-Charset` from being written by the
StringHttpMessageConverter. This feature is enabled by default in the
framework and writes a *quite long* response header with all charsets
supported by the server.

Closes gh-2370, see gh-1800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants