java-express icon indicating copy to clipboard operation
java-express copied to clipboard

There is no way to specify the charset of a response

Open jalberto-ghub opened this issue 4 years ago • 1 comments

Using latest version: 0.2.1

Do you want to request a feature or report a bug? This should really be a bug, but may be thought of as a feature. What is the current behavior? response.send(String s) always uses the default charset s.getBytes() If the current behavior is a bug, please provide the steps to reproduce. Specify response.setContentType("text/plain; charset=UTF-8"); What is the expected behavior? That the String is sent using UTF-8 encoding, but the string is sent using the default charset of the javaVM Please mention your java and java-express version. 0.2.1

Ideally there should be a method on the response for setting the charset and that charset then be used by send. Additionally calling response.contentType(String) should check whether a charset is specified and set it accordingly.

jalberto-ghub avatar Jan 11 '21 21:01 jalberto-ghub

This is addressed in my fork of this project. It is able to determine the charset to use by looking at the content type header.

https://github.com/masecla22/java-express If you want to take a look at it.

masecla22 avatar Sep 11 '21 13:09 masecla22