Dear all,

after being helped into the saddle, I succeeded in writing a small set
of nested loops for creating a CJK character table of a desired scope.

Currently, the table has two important macros:

.line produces a line of 16 characters

.block produces a block of 16 lines

Starting and terminating values are currently in line with the needs of
printing the basic Unicode CJK set, i.e. from U+4300 to U+9FEF.

For the moment, I blindly rush through to U+9FFF without any attempt to
define an appropriate halting condition.

Rather than calculating the hex values for block addresses from U+4E..
to U+9F.., I made another lookup table. Sometimes it helps being lazy.

Usage:

Edit the desired end value (line 6, .nr lastblock) of the attached script.

$ troff -Tutf8 line_in_while_loop.tr | grotty | less

Of course, much more can be done to produce beautiful output, but so far
I am relieved that it works as desired.

Thank you all again for your good advice.

Have a nice Sunday!

Oliver.


--
Dr. Oliver Corff
Mail: oliver.co...@email.de
.\"
.\" Use: troff -Tutf8 line_in_while_loop.tr | grotty
.\"
.pl 2
.nr l 78 1 \" First block starts at U+4E
.nr lastblock 159 \" Maximal value is 159
.\" hex digits
.ds 0 0
.ds 1 1
.ds 2 2
.ds 3 3
.ds 4 4
.ds 5 5
.ds 6 6
.ds 7 7
.ds 8 8
.ds 9 9
.ds 10 A
.ds 11 B
.ds 12 C
.ds 13 D
.ds 14 E
.ds 15 F

.\" For convenience, hex blocks ready-made rather than computed
.\" generated by: perl -e 'for $i (78..150) {printf (".ds %4d \U%2x\n",$i,$i)}'
.ds  78 4E
.ds  79 4F
.ds  80 50
.ds  81 51
.ds  82 52
.ds  83 53
.ds  84 54
.ds  85 55
.ds  86 56
.ds  87 57
.ds  88 58
.ds  89 59
.ds  90 5A
.ds  91 5B
.ds  92 5C
.ds  93 5D
.ds  94 5E
.ds  95 5F
.ds  96 60
.ds  97 61
.ds  98 62
.ds  99 63
.ds 100 64
.ds 101 65
.ds 102 66
.ds 103 67
.ds 104 68
.ds 105 69
.ds 106 6A
.ds 107 6B
.ds 108 6C
.ds 109 6D
.ds 110 6E
.ds 111 6F
.ds 112 70
.ds 113 71
.ds 114 72
.ds 115 73
.ds 116 74
.ds 117 75
.ds 118 76
.ds 119 77
.ds 120 78
.ds 121 79
.ds 122 7A
.ds 123 7B
.ds 124 7C
.ds 125 7D
.ds 126 7E
.ds 127 7F
.ds 128 80
.ds 129 81
.ds 130 82
.ds 131 83
.ds 132 84
.ds 133 85
.ds 134 86
.ds 135 87
.ds 136 88
.ds 137 89
.ds 138 8A
.ds 139 8B
.ds 140 8C
.ds 141 8D
.ds 142 8E
.ds 143 8F
.ds 144 90
.ds 145 91
.ds 146 92
.ds 147 93
.ds 148 94
.ds 149 95
.ds 150 96
.ds 151 97
.ds 152 98
.ds 153 99
.ds 154 9A
.ds 155 9B
.ds 156 9C
.ds 157 9D
.ds 158 9E
.ds 159 9F
.
Test: Print line with first 16 CJK characters:
.br
.nr m 0 1
.nr n 0 1

.while (\n[n] < 16) \{\
\[u4E0\*[\nn]]
.nr n +1
.\}
.
.\" Create macro for complete line
.de line
.nr n 0 1
.while (\\n[n] < 16) \\{\\
\\[u\\*[\\nl]\\*[\\nm]\\*[\\nn]]
.nr n +1
.\\}
..

Test: Print block of 16 CJK lines:
.br
.while (\n[m] < 16) \{\
.line
.br
.nr m +1
.\}

.de block
.nr m 0 1
.while (\\n[m] < 16) \\{\\
\\*[\\n[m]]: 
.line
.br
.nr m +1
.\\}
..

Print blocks of 16 CJK lines from U+\*[\n[l]] up to block U+\*[\n[lastblock]]..:
.br
.while (\n[l] <= \n[lastblock]) \{\
Block \*[\n[l]]
.br
.block
\l'12c'
.br
.nr l +1
.\}

Reply via email to