Browse Source

REPORT-27497 编辑单元格输入韩文时字会缺失 使用java自带方式判断 + 漏传代码

feature/big-screen
hades 4 years ago
parent
commit
e372a89f87
  1. 7
      designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java
  2. 53
      designer-realize/src/main/java/com/fr/grid/help/GridHelper.java
  3. 13
      designer-realize/src/test/java/com/fr/grid/help/GridHelperTest.java

7
designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java

@ -117,6 +117,13 @@ public enum SupportOSImpl implements SupportOS {
public boolean support() {
return OperatingSystem.isWindows();
}
},
KOREAN_INPUT {
@Override
public boolean support() {
return OperatingSystem.isWindows();
}
}
}

53
designer-realize/src/main/java/com/fr/grid/help/GridHelper.java

@ -1,24 +1,53 @@
package com.fr.grid.help;
/**
* 韩文unicode编码范围
* http://www.ch2ko.com/hanguoyu/hanwen-unicode/
*
* 韩文音节AC00-D7AF
* Character.UnicodeBlock.HANGUL_SYLLABLES
* https://www.unicode.org/charts/PDF/UAC00.pdf
*
*
* 韩文兼容字母3130-318F
* Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO
* https://www.unicode.org/charts/PDF/U3130.pdf
*
*
* 韩文字母1100-11FF
* Character.UnicodeBlock.HANGUL_JAMO
* https://www.unicode.org/charts/PDF/U1100.pdf
*
*
* 韩文字母扩展A
* Character.UnicodeBlock.HANGUL_JAMO_EXTENDED_A
* https://www.unicode.org/charts/PDF/UA960.pdf
*
*
* 韩文字母扩展B
* haracter.UnicodeBlock.HANGUL_JAMO_EXTENDED_B
* https://www.unicode.org/charts/PDF/UD7B0.pdf
*
*
* 使用java内部的韩文unicode集判断
*
* @author hades
* @version 10.0
* Created by hades on 2020/8/7
*/
public class GridHelper {
private static final char X_AC00 = 0xAC00;
private static final char X_D7A3 = 0xD7A3;
private static final char X_3130 = 0x3130;
private static final char X_318F = 0x318F;
private static final char X_1100 = 0x1100;
private static final char X_11FF = 0x11FF;
private static final char X_20A9 = 0x20A9;
/**
* 韩国货币符号
*/
private static final char HEX_20A9 = 0x20A9;
public static boolean isKoreanCharacter(char value) {
return value >= X_AC00 && value <= X_D7A3
|| value > X_3130 && value < X_318F
|| value > X_1100 && value < X_11FF
|| value == X_20A9;
Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(value);
return unicodeBlock == Character.UnicodeBlock.HANGUL_JAMO
|| unicodeBlock == Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO
|| unicodeBlock == Character.UnicodeBlock.HANGUL_SYLLABLES
|| unicodeBlock == Character.UnicodeBlock.HANGUL_JAMO_EXTENDED_A
|| unicodeBlock == Character.UnicodeBlock.HANGUL_JAMO_EXTENDED_B
|| value == HEX_20A9;
}
}

13
designer-realize/src/test/java/com/fr/grid/help/GridHelperTest.java

@ -28,6 +28,19 @@ public class GridHelperTest extends TestCase {
Assert.assertFalse(GridHelper.isKoreanCharacter('は'));
Assert.assertTrue(GridHelper.isKoreanCharacter('먀'));
Assert.assertTrue(GridHelper.isKoreanCharacter('이'));
Assert.assertTrue(GridHelper.isKoreanCharacter('한'));
// 韩文音节
Assert.assertTrue(GridHelper.isKoreanCharacter('휖'));
// 韩文兼容字母
Assert.assertTrue(GridHelper.isKoreanCharacter('ㆋ'));
// 韩文字母
Assert.assertTrue(GridHelper.isKoreanCharacter('ᇪ'));
// 韩文字母扩展A
Assert.assertTrue(GridHelper.isKoreanCharacter('ꥵ'));
// 韩文字母扩展B
Assert.assertTrue(GridHelper.isKoreanCharacter('ퟂ'));
// 韩文货币符号
Assert.assertTrue(GridHelper.isKoreanCharacter('₩'));
}

Loading…
Cancel
Save