Re: Freemarker Encoding issue
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Monday, March 8, 2010, 5:30:23 PM, Zhiqiang Huang wrote:
> Hi, there
>
> I'm new to freemarker and I'm using freemarker with servlet. I'm coming across a encoding issue.
> If I put chinese in .ftl, it can be output correctly. But when I
> put chinese in data-model (a hashmap), it can't. The Chinese characters are output as '?'.
> I have tried all the setxxxEncoding methods to set the encoding to "utf-8" and failed.
> Could anyone help me? Thank you very much!
Put a ${"\x6464"} into your template. If in the browser it shows a "?"
instead of a chinese character, then something is still wrong with the
FreeMarker configuration and/or with the java.io.Writer where
FreeMarker prints its output. If ${"\x6464"} shows a chinese
character, and also the chiense text entered directly into the
template shows correctly, then most probably it's the connection to
the data-base server that has an encoding issue. (You can double-check
that if in Java (not in FreeMarker) you log the character codes of the
string... if it contains 63-s, which is the code of '?', the it
already contains the '?'-s when you receive it from the database.)
> Best wishes,
> hzqtc
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev