fork(1) download
  1. import java.text.DecimalFormat;
  2. import java.text.Normalizer;
  3.  
  4. public class Main {
  5. private static String toCodes(final String str) {
  6. StringBuilder sb = new StringBuilder();
  7. for (int i = 0; i < str.length(); ++i) {
  8. sb.append('\\');
  9. sb.append('u');
  10. String hex = Integer.toHexString(str.charAt(i));
  11. for (int j = 4 - hex.length(); j-- > 0;) {
  12. sb.append('0');
  13. }
  14. sb.append(hex);
  15. }
  16. return new String(sb);
  17. }
  18.  
  19. private static void normalize(final String str) {
  20. System.out.println();
  21. System.out.println("From\t" + str + '\t' + toCodes(str));
  22. for (Normalizer.Form form: Normalizer.Form.values()) {
  23. String normalized = Normalizer.normalize(str, form);
  24. System.out.println(
  25. form + "\t" + normalized + '\t' + toCodes(normalized));
  26. }
  27. }
  28.  
  29. public static void main(final String[] args) {
  30. DecimalFormat format = new DecimalFormat("#");
  31. format.setMaximumFractionDigits(20);
  32. System.out.println(format.format(1234567890123456L));
  33. System.out.println(format.format(1234567890123456d));
  34. System.out.println(format.format(1234567890123.456d));
  35. System.out.println(format.format(1234567890.123456d));
  36.  
  37. normalize("\u00c1");
  38. normalize("\u0041\u0301");
  39. normalize("\ufb03");
  40. normalize("ff");
  41. normalize("й");
  42. normalize("\u0438\u0306");
  43. normalize("å");
  44. }
  45. }
Success #stdin #stdout 0.16s 321408KB
stdin
Standard input is empty
stdout
1234567890123456
1234567890123456
1234567890123.456
1234567890.123456

From	Á	\u00c1
NFD	Á	\u0041\u0301
NFC	Á	\u00c1
NFKD	Á	\u0041\u0301
NFKC	Á	\u00c1

From	Á	\u0041\u0301
NFD	Á	\u0041\u0301
NFC	Á	\u00c1
NFKD	Á	\u0041\u0301
NFKC	Á	\u00c1

From	ffi	\ufb03
NFD	ffi	\ufb03
NFC	ffi	\ufb03
NFKD	ffi	\u0066\u0066\u0069
NFKC	ffi	\u0066\u0066\u0069

From	ff	\ufb00
NFD	ff	\ufb00
NFC	ff	\ufb00
NFKD	ff	\u0066\u0066
NFKC	ff	\u0066\u0066

From	й	\u0439
NFD	й	\u0438\u0306
NFC	й	\u0439
NFKD	й	\u0438\u0306
NFKC	й	\u0439

From	й	\u0438\u0306
NFD	й	\u0438\u0306
NFC	й	\u0439
NFKD	й	\u0438\u0306
NFKC	й	\u0439

From	å	\u00e5
NFD	å	\u0061\u030a
NFC	å	\u00e5
NFKD	å	\u0061\u030a
NFKC	å	\u00e5