国际化场景:使用音译接口,将汉字转为拼音:Transliterator转换后字符串支持直接进行比较,包括含音标的字母。参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/i18n-character-processing-0000001774120602\#ZH-CN\_TOPIC\_0000001774120602\_\_音译非国际化场景可以使用@ohos/pinyin4js三方库:ohpm install @ohos/pinyin4jsdemo可以参考:https://gitee.com/openharmony-tpc/pinyin4js
国际化场景:
使用音译接口,将汉字转为拼音:Transliterator转换后字符串支持直接进行比较,包括含音标的字母。
参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/i18n-character-processing-0000001774120602\#ZH-CN\_TOPIC\_0000001774120602\_\_音译
非国际化场景可以使用@ohos/pinyin4js三方库:
ohpm install @ohos/pinyin4jsdemo
可以参考:https://gitee.com/openharmony-tpc/pinyin4js