Howdy,
First of all, my apologies if this functionality is already provided by
velocity. I did search through the docs and mailing list and didn't
find what I was looking for... so, that caveat aside:
I've been working with velocity bit, and one area that seems to be a
little lacking is the ability for templates to specify their own
encoding.
I was wondering if we could add support to allow templates to
(optionally) do so. My first thought was allowing a comment to be the
first line of the file:
## encoding: utf8
which would override the default encoding (and perhaps whatever
encoding is passed in). If there was no encoding specified, then the
current semantics would apply.
Clearly there are some limitations to this approach, the biggest being
that the encoding has to be some kind of ascii-compatible single byte
encoding (although we could also look for the unicode byte order
markers, and respect those, as well).
Also, some might fine having a "special" comment distasteful (although
python, for example, takes this approach for its source files).
Other possibilities include:
1) Having a special directive instead (although it looks like
directives don't currently have any methods invoked
until after the whole file is parsed, which would be problematic
since later encoding-specific content could cause exceptions to
be thrown).
2) Provide a pattern-based approached, where one could define
set a patterns to map to specific encodings. This would
allow one to specific that "*/en/*" maps to "iso-8859-4"
while "*/ja/*" maps to "SJIS." This approach is
not mutually exclusive with having files identify their
own encoding. (JSP 2.0 will provide both approaches, for example)
I think the current approach is a little cumbersome, in that it
requires external meta-data to be kept, but provides no facility for
doing so.
-Charles Morehead
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]