How do you print all Unicode characters in a range - I want the subscripts, can't google a range of Unicode.

rikki cattermole rikki at cattermole.co.nz
Fri Dec 2 05:59:48 UTC 2022


The output will be bad because of Windows specific behavior related to 
not outputting as UTF-16.

This will print all the characters in the block "Superscripts and 
Subscripts".

The Unicode database is very out of date (just waiting for merge for 
update), but should be ok for this example.

```
import std.uni : unicode;
import std.stdio : writefln;
void main() {
     foreach(c; unicode.InSuperscriptsandSubscripts.byCodepoint)
     	writefln!"U+%X = "(c, c);
}
```

Unfortunately I'm not seeing an obvious way of determining 
subscript/superscript from what we have.

You can do it with the help of[0] via Super/Sub field values, which 
originate from UnicodeData.txt's Decomposition_Type field, but you 
shouldn't parse that if you only want just this one set of values.

[0] 
https://www.unicode.org/Public/15.0.0/ucd/extracted/DerivedDecompositionType.txt


More information about the Digitalmars-d-learn mailing list