We are validating a text entered by the user to be under 4000 characters to avoid Oracle errors. We are using the function "len" to do that.
However, the function is not taking into account special characters (but Oracle does). Is there a way to count the real length of a string including special characters such as return line?
are 21 characters including one return line in Oracle.
Can you give an example of the function you tried? In my experience, len() does consider special characters. For example, the result of this expression is 21:
Have you tried "lenb()"? I haven't tested it extensively but it claims to return length in bytes for a string, instead of length in characters - which would usually be the same, except (presumably) for cases like unicode characters that consume more than one byte (which i assume is what you mean by "special characters").
Thanks Peter and Mike. Sorry it was my mistake. Len() does consider special characters. The confusion was caused because
Is considered as 22 characters by Notepad++ and 21 characters by Appian len().
I believe that Notepad++ uses 2 characters for Return line and Appian one, but there is nothing wrong with that.
The one super interesting case I ran into, which would be good to watch out for, is the difference between the search() function and find() function. One is case sensitive, the other is not.
But also, one registers capital I with a dot on top as 1 letter; the other registers it as 2 letters. I think it was search() which is case insensitive and correctly reads letters with accents as 1 letter. If you're using the wrong function to locate the end of an XML file with a few of those special characters in there, you could wind up having a bad day like I did.
Discussion posts and replies are publicly visible
© 2020 Appian. All rights reserved.