19
Views
5
Comments
Length calculation
Question

Hello community,

I noticed that when Using Outsystems 11, web, the Built-in Functions/Text/lenght() function does not appear to count characters the same as the WebPatterns/Utilities/CharacterCount widget.  Should these calculate the length differently?  

When comparing behavior, be sure to use the <enter> key.  This seems to cause a difference between the two.

Thanks!

Witch one counts the <enter>?

 

Rank: #704

They both count <enter>.  If I remember correctly, Utilities/Character counts 2 for <enter> and length() counts 1.

They shouldn't be different but somehow I'm not surprised. 

<enter> is not really a character, is an information to the device to change line and is represented  by two characters (I' don't remember which ones). I seems length() interprets it as one character and Utilities/Character counts the actual space it uses in the field. 

Perhaps what we need is remark in the length() function explaining that. 

Rank: #704

Thanks for your response.  We ended up removing the WebPatterns/Utilities/CharacterCount widget and writing our own that calculated using length(), so everything would match.

Good !Problem solved! 

But, if you are writing the text in a file field with a limited number of characters , you should verify if the string is not cut in the end when you reach the limit length.