是否有一个不被视为空白的隐形字符? [英] Is there an invisible character that is not regarded as whitespace?

查看:155
本文介绍了是否有一个不被视为空白的隐形字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用现有框架,如果满足某些条件,我必须将某个属性设置为空白。不幸的是,框架不允许仅将空格设置为属性值。具体来说,它确实

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))检查值

是否有可能以某种方式绕过这个并设置一个看起来空白/不可见的值但不被视为空白的值?

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字符'ZERO WIDTH SPACE'(U + 200B)。根据 WP:Whitespace#Unicode

StringUtils.isBlank 不会打扰它:

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;
  }

这篇关于是否有一个不被视为空白的隐形字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆