I am working with an existing framework where I have to set a certain attribute to blank if some conditions are satisfied. Unfortunately, the framework doesn't allow setting only whitespace to the attribute value. Specifically, it does a
!(org.apache.commons.lang.StringUtils.isBlank(value))
check on the value
Is it possible to somehow bypass this and set a value that looks blank/invisible to the eye but is not regarded as whitespace?
I am using a dash "-" right now, but I think it would be interesting to know if it's possible.
Unicode characters you can not see In Unicode there are a lot of invisible characters: regular white-space characters (e.g. U+0020 SPACE), language specific fillers (e.g. U+3164 HANGUL FILLER of the Korean Hangual alphabet), or special characters (e.g. U+2800 BRAILLE PATTERN BLANK).
In word processing and digital typesetting, a non-breaking space, , also called NBSP, required space, hard space, or fixed space (though it is not of fixed width), is a space character that prevents an automatic line break at its position.
There is actually a truly invisible character: U+FEFF . This character is called the Byte Order Mark and is related to the Unicode 8 system. It is a really confusing concept that can be explained HERE The Byte Order Mark or BOM for short is an invisible character that doesn't take up any space.
Try Unicode Character 'ZERO WIDTH SPACE' (U+200B). It is not a Whitespace according to WP: Whitespace#Unicode
The code of StringUtils.isBlank
will not bother it:
public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) { return false; } } return true; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With