Skip to content

Commit ea2711d

Browse files
Manishearthsffc
authored andcommitted
ICU-22270 Use hex for mask properties
1 parent f0ca9f5 commit ea2711d

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

icu4c/source/tools/icuexportdata/icuexportdata.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,18 @@ void dumpBinaryProperty(UProperty uproperty, FILE* f) {
170170

171171
// If the value exists, dump an indented entry of the format
172172
// `" {discr = <discriminant>, long = <longname>, short = <shortname>, aliases = [<aliases>]},"`
173-
void dumpValueEntry(UProperty uproperty, int v, FILE* f) {
173+
void dumpValueEntry(UProperty uproperty, int v, bool is_mask, FILE* f) {
174174
const char* fullValueName = u_getPropertyValueName(uproperty, v, U_LONG_PROPERTY_NAME);
175175
const char* shortValueName = u_getPropertyValueName(uproperty, v, U_SHORT_PROPERTY_NAME);
176176
if (!fullValueName) {
177177
return;
178178
}
179-
fprintf(f, " {discr = %i, long = \"%s\"", v, fullValueName);
179+
if (is_mask) {
180+
fprintf(f, " {discr = 0x%X", v);
181+
} else {
182+
fprintf(f, " {discr = %i", v);
183+
}
184+
fprintf(f, ", long = \"%s\"", fullValueName);
180185
if (shortValueName) {
181186
fprintf(f, ", short = \"%s\"", shortValueName);
182187
}
@@ -220,7 +225,7 @@ void dumpEnumeratedProperty(UProperty uproperty, FILE* f) {
220225

221226
fprintf(f, "values = [\n");
222227
for (int v = minValue; v <= maxValue; v++) {
223-
dumpValueEntry(uproperty, v, f);
228+
dumpValueEntry(uproperty, v, false, f);
224229
}
225230
fprintf(f, "]\n");
226231

@@ -251,7 +256,7 @@ void dumpEnumeratedProperty(UProperty uproperty, FILE* f) {
251256
// after the property in the listing
252257
void maybeDumpMaskValue(UProperty uproperty, uint32_t v, uint32_t mask, FILE* f) {
253258
if (U_MASK(v) < mask && U_MASK(v + 1) > mask)
254-
dumpValueEntry(uproperty, mask, f);
259+
dumpValueEntry(uproperty, mask, true, f);
255260
}
256261

257262
void dumpGeneralCategoryMask(FILE* f) {
@@ -274,7 +279,7 @@ void dumpGeneralCategoryMask(FILE* f) {
274279

275280
fprintf(f, "values = [\n");
276281
for (uint32_t v = minValue; v <= maxValue; v++) {
277-
dumpValueEntry(uproperty, U_MASK(v), f);
282+
dumpValueEntry(uproperty, U_MASK(v), true, f);
278283

279284
// We want to dump these masks "in order", which means they
280285
// should come immediately after every property they contain

0 commit comments

Comments
 (0)