micronaut-views icon indicating copy to clipboard operation
micronaut-views copied to clipboard

No charset encoding specified on view responses

Open mikehearn opened this issue 11 months ago • 0 comments

Expected Behavior

Unless otherwise specified, HTTP responses from Micronaut (Views) should declare that they are in UTF-8 in the Content-Type header.

Actual Behaviour

No encoding is specified, leaving the browser to guess, and sometimes it guesses wrong.

Steps To Reproduce

  1. Make a view that includes the output of something like DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).format(LocalDateTime.now()) which should yield a unicode NNBSP character before the "AM" or "PM" part.
  2. Load it in Chrome.
  3. Observe mojibake
  4. Add a <meta charset="utf-8"/> tag to the header.
  5. Observe that it's now fixed.

Environment Information

macOS 14, Chrome

Example Application

No response

Version

4.3.6

mikehearn avatar Mar 25 '24 16:03 mikehearn