You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by ChadDavis <ch...@gmail.com> on 2011/01/10 21:27:09 UTC

getTemplate with encoding

If I'm obtaining my template with the following:

velocityEngine.getTemplate ( "myTemplate", "UTF-8" );

What will happen if the template is not encoded in UTF-8?  Will the template
be processed, even if incorrectly, and used?  Or will the template be turned
down immediately?

Re: getTemplate with encoding

Posted by ChadDavis <ch...@gmail.com>.
Thank you!

On Mon, Jan 10, 2011 at 4:14 PM, Nathan Bubna <nb...@gmail.com> wrote:

> On Mon, Jan 10, 2011 at 1:07 PM, ChadDavis <ch...@gmail.com>
> wrote:
> > On Mon, Jan 10, 2011 at 1:48 PM, <ap...@recks.org> wrote:
> >
> >> If the file has only ASCII characters (7 bit) everything will work OK.
> >> If it has binary content or other encoding, you will most probably have
> >> some funny characters in your output.
> >> Since some very few byte sequences are invalid UTF8, I'm not sure, but
> it
> >> could cause an IO exception.
> >>
> >>
> > In other words, you would still expect it to merge the template?  I was
> > wondering if one of my resource loaders was refusing the template because
> it
> > was latin-1, and the lookup was falling through to another loader which
> had
> > a UTF-8 template.  But, from what I understand from your response, it
> > doesn't sound like this would be the case.
>
> yes, garbled content is your risk.
>
> > If one loader finds a template, and the engine blows up on merging, does
> the
> > engine go to the next loader?  I think now, but I'm not entirely sure.
>
> no, failed merge ends there.  velocity doesn't go back to resource finding.
>
> >
> >> :) Christoph
> >>
> >>
> >>
> >> ChadDavis on 2011-01-10 21:27 wrote:
> >>
> >>> If I'm obtaining my template with the following:
> >>>
> >>> velocityEngine.getTemplate ( "myTemplate", "UTF-8" );
> >>>
> >>> What will happen if the template is not encoded in UTF-8?  Will the
> >>> template
> >>> be processed, even if incorrectly, and used?  Or will the template be
> >>> turned
> >>> down immediately?
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: user-help@velocity.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Re: getTemplate with encoding

Posted by Nathan Bubna <nb...@gmail.com>.
On Mon, Jan 10, 2011 at 1:07 PM, ChadDavis <ch...@gmail.com> wrote:
> On Mon, Jan 10, 2011 at 1:48 PM, <ap...@recks.org> wrote:
>
>> If the file has only ASCII characters (7 bit) everything will work OK.
>> If it has binary content or other encoding, you will most probably have
>> some funny characters in your output.
>> Since some very few byte sequences are invalid UTF8, I'm not sure, but it
>> could cause an IO exception.
>>
>>
> In other words, you would still expect it to merge the template?  I was
> wondering if one of my resource loaders was refusing the template because it
> was latin-1, and the lookup was falling through to another loader which had
> a UTF-8 template.  But, from what I understand from your response, it
> doesn't sound like this would be the case.

yes, garbled content is your risk.

> If one loader finds a template, and the engine blows up on merging, does the
> engine go to the next loader?  I think now, but I'm not entirely sure.

no, failed merge ends there.  velocity doesn't go back to resource finding.

>
>> :) Christoph
>>
>>
>>
>> ChadDavis on 2011-01-10 21:27 wrote:
>>
>>> If I'm obtaining my template with the following:
>>>
>>> velocityEngine.getTemplate ( "myTemplate", "UTF-8" );
>>>
>>> What will happen if the template is not encoded in UTF-8?  Will the
>>> template
>>> be processed, even if incorrectly, and used?  Or will the template be
>>> turned
>>> down immediately?
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: getTemplate with encoding

Posted by ChadDavis <ch...@gmail.com>.
On Mon, Jan 10, 2011 at 1:48 PM, <ap...@recks.org> wrote:

> If the file has only ASCII characters (7 bit) everything will work OK.
> If it has binary content or other encoding, you will most probably have
> some funny characters in your output.
> Since some very few byte sequences are invalid UTF8, I'm not sure, but it
> could cause an IO exception.
>
>
In other words, you would still expect it to merge the template?  I was
wondering if one of my resource loaders was refusing the template because it
was latin-1, and the lookup was falling through to another loader which had
a UTF-8 template.  But, from what I understand from your response, it
doesn't sound like this would be the case.

If one loader finds a template, and the engine blows up on merging, does the
engine go to the next loader?  I think now, but I'm not entirely sure.


> :) Christoph
>
>
>
> ChadDavis on 2011-01-10 21:27 wrote:
>
>> If I'm obtaining my template with the following:
>>
>> velocityEngine.getTemplate ( "myTemplate", "UTF-8" );
>>
>> What will happen if the template is not encoded in UTF-8?  Will the
>> template
>> be processed, even if incorrectly, and used?  Or will the template be
>> turned
>> down immediately?
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Re: getTemplate with encoding

Posted by ap...@recks.org.
If the file has only ASCII characters (7 bit) everything will work OK.
If it has binary content or other encoding, you will most probably have some funny characters in your output.
Since some very few byte sequences are invalid UTF8, I'm not sure, but it could cause an IO exception.

:) Christoph


ChadDavis on 2011-01-10 21:27 wrote:
> If I'm obtaining my template with the following:
>
> velocityEngine.getTemplate ( "myTemplate", "UTF-8" );
>
> What will happen if the template is not encoded in UTF-8?  Will the template
> be processed, even if incorrectly, and used?  Or will the template be turned
> down immediately?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org