Thread overview
How do you print all Unicode characters in a range - I want the subscripts, can't google a range of Unicode.
Dec 02, 2022
rikki cattermole
Dec 03, 2022
Adam D Ruppe
Dec 03, 2022
Adam D Ruppe
Dec 03, 2022
Adam D Ruppe
December 02, 2022
	dstring s = "";
	for (dchar i='ₐ'; i < 'ₜ'; i++)
		s ~= i;
	writeln(s);

Doesn't work. The result I get is shit:

ₐₑₒₓₔₕₖₗₘₙₚₛ

December 02, 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
December 03, 2022
On Friday, 2 December 2022 at 05:27:40 UTC, Daniel Donnelly, Jr. wrote:
> Doesn't work.  The result I get is shit:

The problem is just that writeln to the console is broken. You can either write to a function instead and load it in a text editor, or use a non-broken writeln like my terminal.d's

```
void main() {
        // using the same string...
        dstring s = "";
        for (dchar i='ₐ'; i < 'ₜ'; i++)
                s ~= i;

        // this will output correctly
        import arsd.terminal;
        auto terminal = Terminal(ConsoleOutputMode.linear);
        terminal.writeln(s);

        // this will not
        import std.stdio;
        writeln(s);
}
```

Screenshot output:
http://arsdnet.net/dcode/writelnsux.png


Now, while it outputs correctly, you'll still note a bunch of empty boxes. That's because the *font* I'm using doesn't include those characters. If you changed fonts there's a decent chance you can see those too.
December 03, 2022
On Saturday, 3 December 2022 at 14:43:15 UTC, Adam D Ruppe wrote:
>         import arsd.terminal;

oh yeah my module:

can download direct and compile with your program
https://github.com/adamdruppe/arsd/blob/master/terminal.d

or it is also on dub
https://code.dlang.org/packages/arsd-official%3Aterminal
December 03, 2022
On Saturday, 3 December 2022 at 14:43:15 UTC, Adam D Ruppe wrote:
> The problem is just that writeln to the console is broken. You can either write to a function instead and load it in a text editor

aaargh not to a "function" i meant to a "file".

like

auto f = File("test.txt", "wt");
f.writeln(s);


then open test.txt and make sure it is opened in utf-8 mode.