Freemarker encoding - question marks in the place of accented characters

后端 未结 4 2087
死守一世寂寞
死守一世寂寞 2021-01-12 16:02

I am trying to print accented characters with Freemarker, but in the place of accented characters, I get only question marks. I have verified, that following statement holds

4条回答
  •  别那么骄傲
    2021-01-12 16:42

    FreeMarker always treats text as UNICODE, so it doesn't generate question marks. Since the accented letters aren't coming from the templates (if I understand it well), it must be your output encoding that's improper. See also: http://freemarker.org/docs/app_faq.html#faq_questionmark

    BTW, getDefaultEncoding() has no role in this. That influences the decoding used when you load the templates, but you are saying that the accented characters aren't coming from the template file, also I don't think you can get ?-s from decoding (unless, for invalid UTF-8 byte sequences). As of the encoding of the output, FreeMarker just uses a Writer (as opposed to an OutputStream), so it can't influence that.

提交回复
热议问题