harmony-utils之CharUtil,字符工具类 电子说
harmony-utils 一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志、异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和作,能够满足各种不同的开发需求。
picker_utils 是harmony-utils拆分出来的一个子库,包含 PickerUtil、PhotoHelper、ScanUtil。
下载安装ohpm i @pura/harmony-utilsohpm i @pura/picker_utils
//全局初始化方法,在UIAbility的onCreate方法中初始化 AppUtil.init()
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
AppUtil.init(this.context);
}
let b1 = CharUtil.isDigit('6');
let b2 = CharUtil.isDigit('A');
let b3 = CharUtil.isDigit('瑶');
let b4 = CharUtil.isDigit('6a');
let bl1 = CharUtil.isLetter('A');
let bl2 = CharUtil.isLetter('6');
let bl3 = CharUtil.isLetter('瑶');
let bl4 = CharUtil.isLetter('a6');
let b1 = CharUtil.isLowerCase('a');
let b2 = CharUtil.isLowerCase('ad');
let b3 = CharUtil.isLowerCase('瑶');
let b4 = CharUtil.isLowerCase('6abc');
let b5 = CharUtil.isLowerCase('Abc');
let b6 = CharUtil.isLowerCase('aBC');
let bl1 = CharUtil.isUpperCase('A');
let bl2 = CharUtil.isUpperCase('AB');
let bl3 = CharUtil.isUpperCase('瑶');
let bl4 = CharUtil.isUpperCase('6cba');
let bl5 = CharUtil.isUpperCase('cBA');
let bl6 = CharUtil.isUpperCase('Cba');
let b1 = CharUtil.isSpaceChar(' ');
let b2 = CharUtil.isSpaceChar('a d');
let b3 = CharUtil.isSpaceChar('a ');
let b4 = CharUtil.isSpaceChar(' ');
let bl1 = CharUtil.isWhitespace(' ');
let bl2 = CharUtil.isWhitespace('A B');
let bl3 = CharUtil.isWhitespace('a ');
let bl4 = CharUtil.isWhitespace(' ');
let b1 = CharUtil.isRTL('我尼玛');
let b2 = CharUtil.isRTL('ad');
let b3 = CharUtil.isRTL('瑶');
let b4 = CharUtil.isRTL('6abc');
let b5 = CharUtil.isRTL('Abc');
let b6 = CharUtil.isRTL('aBC');
let bl1 = CharUtil.isIdeograph('我尼玛');
let bl2 = CharUtil.isIdeograph('AB');
let bl3 = CharUtil.isIdeograph('ABC瑶');
let bl4 = CharUtil.isIdeograph('我尼玛6cba');
let bl5 = CharUtil.isIdeograph('cBA');
let bl6 = CharUtil.isIdeograph('Cba');
let b1 = CharUtil.isBlankChar(6);
let b2 = CharUtil.isBlankChar(126);
let b3 = CharUtil.isBlankChar(666);
let b4 = CharUtil.isBlankChar(66666);
let bl1 = CharUtil.isAscii('A');
let bl2 = CharUtil.isAscii('B');
let bl3 = CharUtil.isAscii('瑶');
let bl4 = CharUtil.isAscii('6cba');
审核编辑 黄宇
全部0条评论
快来发表一下你的评论吧 !