Java 怎么判断是有效的XML字符

2019年8月9日22:17:20Java 怎么判断是有效的XML字符已关闭评论 558 503字阅读1分40秒

1.简介

Java 怎么判断是有效的XML字符?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

 


public class Main {
    public static void main(String[] argv) throws Exception {
        int codePoint = 2;
        System.out.println(isValidXMLChar(codePoint));
    }

    public static boolean isValidXMLChar(int codePoint) {
        if (codePoint < 0x20) {
            if (codePoint != 0x09 && codePoint != 0x0A && codePoint != 0x0D) {
                return false;
            }
        } else if (codePoint >= 0x20 && codePoint <= 0xD7FF) {
        } else if (codePoint >= 0xE000 && codePoint <= 0xFFFD) {
        } else if (codePoint >= 0x10000 && codePoint <= 0x10FFFF) {
        } else {
            return false;
        }
        return true;
    }
}

 
编程十万个怎么办