package com.example.demo.common;

public class EmojiTool {
    /**
     *  把emoji表情替换为指定字符
     */
    public static String replaceEmoji(String source, String slipStr) {
        if (isBlank(source)) return source;
        return source.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", slipStr);
    }

    /**
     * 判断是否为空白字符串
     */
    public static boolean isBlank(CharSequence cs) {
        int strLen;
        if (cs != null && (strLen = cs.length()) != 0) {
            for(int i = 0; i < strLen; ++i) {
                if (!Character.isWhitespace(cs.charAt(i))) {
                    return false;
                }
            }
        }
        return true;
    }
}
