Encoding problems with Apache Velocity include
I have a velocity/html file. I'm trying to include/parse some simple HTML into a page.
If I just copy the text directly on the the main file, it works fine:
Miranda Kerr hasn’t been a Victoria’s Secret Angel for ...
If I create a separat开发者_运维百科e VM file, and include it like so:
#parse("topicoftheday/homepagenews.vm")
I get bad character garbage:
Miranda Kerr hasn’t been a Victoria’s Secret Angel for
How? Why?
Thanks
Looks like you have 3 encodings used,
- The VM file in UTF-8.
- The Velocity in Latin-1.
- The terminal/JVM in ANSI.
You are using the non-ASCII apostrophe U+2019. The UTF-8 sequence is E2 80 19, happens to be the 3 chars you see in Latin-1 displayed as ANSI.
You need to change all of them to UTF-8 because Latin-1/ANSI don't have this character. Or you should use ASCII apostrophe '.
For velocity, set this parameter,
input.encoding = UTF-8
精彩评论