开发者

Encoding problems with Apache Velocity include

开发者 https://www.devze.com 2022-12-12 16:07 出处:网络
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:

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,

  1. The VM file in UTF-8.
  2. The Velocity in Latin-1.
  3. 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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号