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

Create resource including Chinese words (encoding by UTF-8) issue #60

shvoidlee opened this Issue Dec 11, 2014 · 1 comment


None yet
2 participants

shvoidlee commented Dec 11, 2014

I testing IGenericClient to create resource with some Chinese words as below:

String name = "測試醫院";
Organization org = new Organization();
        org.setName(new String(name.getBytes(), "UTF-8")).addIdentifier("2.16.886.101.20003.20014.20006", "1531000001");
MethodOutcome mo = client.create().resource(org)

Console Log:
2014/12/11 18:01:58 interceptRequest
Client request body:

<Organization xmlns=""><identifier><system value="2.16.886.101.20003.20014.20006"/><value value="1531000001"/></identifier><name value="測試醫院"/><telecom><value value="0912345678"/></telecom><location><reference value=""/></location></Organization>

It success at
but the name of Organization is garbled. It seems reading by "ISO-8859-1".

Then I try to sent same xml by POSTMAN (a chrome plugin tool)
It success at
there is no garbled.

I try to modify class

entity = new StringEntity(contents, ContentType.create(contentType, "UTF-8"));
entity.setContentEncoding("UTF-8");  // add this line after new StringEntity

same result, Chinese word still become garbled.
Is the client issue or server issue? Thanks.


This comment has been minimized.


jamesagnew commented Dec 16, 2014

Thanks for reporting!
This turned out to be a client issue: The client isn't including the charset declaration in the content-type header for POST/PUT requests. I've fixed it, so this should be available in the next snapshot and in 0.8 final (which will be released any day now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment