Skip to content

Commit

Permalink
gracefully handle missing radical-stroke data
Browse files Browse the repository at this point in the history
  • Loading branch information
markusicu committed Apr 26, 2023
1 parent 311940a commit 6c35780
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions unicodetools/src/main/java/org/unicode/text/UCA/RadicalStroke.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,16 @@ public String getRadicalStringFromShortData(int data) {

private int getUnifiedIdeographForRadicalNumberAndSimplified(int radicalNumberAndSimplified) {
String radicalChars = radToChars[radicalNumberAndSimplified];
if (radicalChars == null) {
int radical = radicalNumberAndSimplified >> SIMPLIFIED_NUM_BITS;
int simplified = radicalNumberAndSimplified & ((1 << SIMPLIFIED_NUM_BITS) - 1);
if (radical == MAX_RADICAL_NUMBER && simplified == 2) {
// Special entry for missing radical-stroke data.
return '?';
}
throw new IllegalArgumentException(
"no radToChars for " + radical + "'''".substring(0, simplified));
}
int length = radicalChars.length();
// All radical characters should be BMP characters.
// Unicode 15.1 exception: 182'' --> U+322C4
Expand Down

0 comments on commit 6c35780

Please sign in to comment.