Browse Source

printdata: add the properties to the primary data map

master
Reece H. Dunn 8 years ago
parent
commit
ceda811b12
4 changed files with 9 additions and 22 deletions
  1. 2
    6
      tests/printcdata.c
  2. 2
    6
      tests/printucddata.c
  3. 2
    6
      tests/printucddata_cpp.cpp
  4. 3
    4
      tools/printdata.py

+ 2
- 6
tests/printcdata.c View File

@@ -178,10 +178,6 @@ void uprintf(FILE *out, codepoint_t c, const char *format)
case 'U': // uppercase
uprintf_codepoint(out, towupper(c), *++format);
break;
case 'W': // whitespace
if (iswspace(c))
fputs("White_Space", out);
break;
}
++format;
break;
@@ -218,7 +214,7 @@ void print_file(FILE *in, const char *format)
{
codepoint_t c = 0;
while (fget_utf8c(in, &c))
uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%W\n");
uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%is\n");
}

int main(int argc, char **argv)
@@ -252,7 +248,7 @@ int main(int argc, char **argv)
else
{
for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %W\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n");
}
return 0;
}

+ 2
- 6
tests/printucddata.c View File

@@ -175,10 +175,6 @@ void uprintf(FILE *out, codepoint_t c, const char *format)
case 'U': // uppercase
uprintf_codepoint(out, ucd_toupper(c), *++format);
break;
case 'W': // whitespace
if (ucd_isspace(c))
fputs("White_Space", out);
break;
}
++format;
break;
@@ -215,7 +211,7 @@ void print_file(FILE *in, const char *format)
{
codepoint_t c = 0;
while (fget_utf8c(in, &c))
uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%W\n");
uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%is\n");
}

int main(int argc, char **argv)
@@ -247,7 +243,7 @@ int main(int argc, char **argv)
else
{
for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %W\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n");
}
return 0;
}

+ 2
- 6
tests/printucddata_cpp.cpp View File

@@ -175,10 +175,6 @@ void uprintf(FILE *out, ucd::codepoint_t c, const char *format)
case 'U': // uppercase
uprintf_codepoint(out, ucd::toupper(c), *++format);
break;
case 'W': // whitespace
if (ucd::isspace(c))
fputs("White_Space", out);
break;
}
++format;
break;
@@ -215,7 +211,7 @@ void print_file(FILE *in, const char *format)
{
ucd::codepoint_t c = 0;
while (fget_utf8c(in, c))
uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%W\n");
uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%is\n");
}

int main(int argc, char **argv)
@@ -247,7 +243,7 @@ int main(int argc, char **argv)
else
{
for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %W\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n");
}
return 0;
}

+ 3
- 4
tools/printdata.py View File

@@ -1,6 +1,6 @@
#!/usr/bin/python

# Copyright (C) 2012 Reece H. Dunn
# Copyright (C) 2012-2017 Reece H. Dunn
#
# This file is part of ucd-tools.
#
@@ -28,11 +28,10 @@ unicode_chars = {}
for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'):
for codepoint in data['CodePoint']:
unicode_chars[codepoint] = data
unicode_chars[codepoint]['Properties'] = []
for data in ucd.parse_ucd_data(ucd_rootdir, 'PropList'):
if data['Property'] in ['White_Space']:
for codepoint in data['Range']:
unicode_chars[codepoint]['Properties'].append(data['Property'])
unicode_chars[codepoint][data['Property']] = 1
for data in ucd.parse_ucd_data(ucd_rootdir, 'Scripts'):
for codepoint in data['Range']:
unicode_chars[codepoint]['Script'] = data['Script']
@@ -60,4 +59,4 @@ if __name__ == '__main__':
codepoint, script,
data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
upper, lower, title,
' '.join(data.get('Properties', []))))
data.get('White_Space', 0)))

Loading…
Cancel
Save