| 1 |
# UnicodeData_h.praat |
| 2 |
# Paul Boersma, 21 June 2025 |
| 3 |
|
| 4 |
Text writing preferences: "UTF-8" |
| 5 |
|
| 6 |
table = Read Table from semicolon-separated file: "UnicodeData 16.0.txt" |
| 7 |
numberOfRows = Get number of rows |
| 8 |
|
| 9 |
stopwatch |
| 10 |
outfile$ = "UnicodeData.h" |
| 11 |
writeFileLine: outfile$, "/* This file was generated automatically by generate/Unicode/UnicodeData_h.praat */" |
| 12 |
|
| 13 |
for irow from 2 to numberOfRows |
| 14 |
code$ = Get value: irow, "code" |
| 15 |
name$ = Get value: irow, "name" |
| 16 |
if name$ = "<control>" |
| 17 |
dum1$ = Get value: irow, "dum1" |
| 18 |
if dum1$ = "" |
| 19 |
name$ = "CONTROL_" + code$ |
| 20 |
else |
| 21 |
name$ = "CONTROL_" + dum1$ |
| 22 |
endif |
| 23 |
endif |
| 24 |
if left$ (name$) <> "<" |
| 25 |
positionOfParenthesis = index (name$, "(") |
| 26 |
if positionOfParenthesis <> 0 |
| 27 |
name$ = left$ (name$, positionOfParenthesis - 2) |
| 28 |
endif |
| 29 |
name$ = replace$ (name$, " ", "_", 0) |
| 30 |
name$ = replace$ (name$, "-", "_", 0) |
| 31 |
appendFileLine: outfile$, |
| 32 |
... "#define UNICODE_" + name$ + “ 0x” + code$, newline$, |
| 33 |
... "#define UNITEXT_" + name$ + if length (code$) = 5 then “ U"\U000” else “ U"\u” fi + code$ + “"” |
| 34 |
endif |
| 35 |
endfor |
| 36 |
appendInfoLine: stopwatch |