Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 separate 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

like image 912
Nathan H Avatar asked Dec 06 '25 18:12

Nathan H


1 Answers

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
like image 118
ZZ Coder Avatar answered Dec 08 '25 11:12

ZZ Coder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!