If I recall Unicode-ware FileResourceLoader was an optional loader in Velocity 1.4 release. Then later (1.5?) it was integrated to a default FileResourceLoader implementation.
Probably you were using non-unicode aware loader back in v1.4 relase, thus got a leading hidden bom characters. Current one, if unicode=true enabled, reads UTF-8, UTF-16LE, UTF-16BE and UTF-32 files and drops bom mark. --- On Mon, 4/20/09, jian chen <[email protected]> wrote: > From: jian chen <[email protected]> > Subject: Re: special characters in templates > To: "Velocity Users List" <[email protected]> > Date: Monday, April 20, 2009, 7:40 PM > Good insight. > > Another thing I found out while using Velocity and UTF-8 > text (this is Velocity 1.4 by the way), if the BOM marker is there in the > text file, Velocity tend to leave a blank line (in terms of html output) > after parsing it. > > So, I have tried to stay away from BOM marker for the > templates. Unless Velocity is fixed with that problem in the latest release. > Just something to point out as per my experience. > > Cheers, > > Jian > http://www.JiansNet.com > > > > On Mon, Apr 20, 2009 at 1:08 AM, mailmur <[email protected]> > wrote: > > > > > I have used UTF-8 with BOM marker .vm text files for > several years now, all > > applications are from client to appserver to files to > db all UTF-8 enabled. > > No more character problems. After all this is year > 2009 so why use ISO-* > > legacy charsets. > > > > I recommend to use it with BOM marker save format so > text editors know > > exactly what to use. Window Notepad.exe works fine if > you use file/save > > as/UTF-8 format. Do not use Windows Write.exe it > breaks utf8 files. > > NotePad++ is good alternative editor as well. > > > > > > _Most Velocity template loaders _are broken_ if you > ask me, they do not > > handle unicode files properly. Only loader to work is > FileResourceLoader its > > a reason I use use it and other loaders are obsolete > to me > > > > > > * use FileResourceLoader instance > > * add "file.resource.loader.unicode=true" attribute to > enable unicode aware > > file loader > > * save files as UTF-8 with BOM marker > > > > Unfortunately this attribute is not well > documented(?), but its been here > > for few years now. See source code for more > information :-) > > > > http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java?revision=743616&view=markup > > > > Internally its using this UnicodeInputStream > implementation, you don't need > > to download anything its there already out of the > box. > > http://koti.mbnet.fi/akini/java/unicodereader/ > > > > > > > > --- On Thu, 4/16/09, jian chen <[email protected]> > wrote: > > > > > From: jian chen <[email protected]> > > > Subject: Re: special characters in templates > > > To: "Velocity Users List" <[email protected]> > > > Date: Thursday, April 16, 2009, 11:20 PM > > > I would recommend that you use UTF-8 > > > when handling the templates. That works > > > fine for both Windows and Linux. > > > > > > Jian > > > http://www.JiansNet.com > > > > > > On Thu, Apr 16, 2009 at 1:28 AM, <[email protected]> > > > wrote: > > > > > > > Hi, > > > > > > > > special characters in a text are stored with > one of > > > many file encodings. > > > > Typical for western windows systems is > CP1252, for > > > Unix systems it is either > > > > IS08859-1, ISO-8859-15 or UTF8. > > > > > > > > Most of these character sets do not provide > a marker > > > system to tell the > > > > reading application how to interpret the > bytes into > > > characters (UTF may use > > > > an initial marker for this purpose, but few > editors > > > only use it). So you > > > > need to tell your application yourself. > > > > > > > > See how to tell velocity how to read your > templates: > > > > > > > > > > http://velocity.apache.org/engine/devel/developer-guide.html#Velocity_Configuration_Keys_and_Values > > > > with the Character Encoding configuration > options. > > > > > > > > If you are using the velocity engine > directly, see: > > > > > > > > > > http://velocity.apache.org/engine/releases/velocity-1.6.2/developer-guide.html#Template_Encoding_for_Internationalization > > > > > > > > > > > > The output.encoding property must be set > according to > > > the downstream > > > > application that will read the produced > output. With > > > web applications you > > > > can ask the request character encoding > property and > > > set the velocity writer > > > > accordingly (the encoding is dynamic and the > web > > > client can request to use a > > > > different one than the default of your > server). With > > > XML it must match the > > > > encoding declared in the first XML line. > > > > > > > > Kind regards, > > > > Christoph > > > > > > > > > > > > Moreno Lopez, Eva Maria wrote: > > > > > Hello, > > > > > > > > > > We are generating a Word template in > our > > > application. In windows all > > > > works ok, but in linux, when the value > associated with > > > the variables of the > > > > template have special characters ( ñ, ´, > eg..) , the > > > word document generated > > > > by velocity doesn´t recognise that > speciall > > > characters. > > > > > > > > > > > > > > > > > > > > Can anybody help us, please? > > > > > > > > > > > > > > > > > > > > Thanks. > > > > > > > > > > > > > > > > > > > > Eva Mª Moreno López > > > > > > > > > > Centro Mixto de I+D de Software Indra - > UCLM > > > > > > > > > > Ronda de Toledo s/n > > > > > > > > > > 13005 Ciudad Real (España) > > > > > > > > > > Tel.: (+34) 926 012 120 - > ext. 28970 > > > > > > > > > > [email protected] > > > <mailto:[email protected]> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
