Normalizer_demo

参考:(15条消息) Java之Normalizer(归一化)_java normalizer_oscar999的博客-CSDN博客

(15条消息) 关于Normalizer.normalize()方法的用途_逆光下的轮廓的博客-CSDN博客

全角字符和半角字符的区别 - 知乎 (zhihu.com)

从⽅不是方到Unicode正规化NFD, NFC, NFKD, NFKC - 小不的笔记 (xobo.org)

Main.java

 1 package com.hmb;
 2 
 3 import java.text.Normalizer;
 4 
 5 public class Main {
 6     public static void main(String[] args) {
 7         // 归一化前
 8         String str1 = "\u00C1";
 9         System.out.println(str1);
10 
11         String str2 = "\u0041" + "\u0301";
12         System.out.println(str2);
13         System.out.println(str1.equals(str2));
14         System.out.println("=====after normalizer====");
15 
16         str1 = Normalizer.normalize(str1, Normalizer.Form.NFKC);
17         str2 = Normalizer.normalize(str2, Normalizer.Form.NFKC);
18         System.out.println(str1);
19         System.out.println(str2);
20         System.out.println(str1.equals(str2));
21     }
22 }

 执行结果

 

posted @ 2023-06-28 00:21  hemeiwolong  阅读(75)  评论(0编辑  收藏  举报