[ 
https://issues.apache.org/jira/browse/FREEMARKER-219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17743461#comment-17743461
 ] 

Simon commented on FREEMARKER-219:
----------------------------------

This seems to be related to how leading and trailing whitespace are handled.

So the following gives the expected output of 2:
{code:java}
${"1 3"?truncate_c(2, '')?length} {code}
While a different string of the same length incorrectly outputs 0:
{code:java}
${" 2 "?truncate_c(2, '')?length} {code}
Targeted tests for trailing and leading whitespace also incorrectly output 0:
{code:java}
${"1 "?truncate_c(1, '')?length}
${" 2"?truncate_c(1, '')?length} {code}

> truncate_c is not working as expected
> -------------------------------------
>
>                 Key: FREEMARKER-219
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-219
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.31
>            Reporter: Mirlan
>            Assignee: Dániel Dékány
>            Priority: Major
>
> So the String I would like to truncate is {{1234 SOMESTREETSSS AVE NE 123}} 
> So the code is as below
> <#assign myField = "1234 SOMESTREETSSS AVE NE 123">
> ${myField?truncate_c(25, '')}
> {{}}
> Expected output is {{1234 SOMESTREETSSS AVE NE}} 
> Actual output is {{1234 SOMESTREETSSS AVE N}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to