Konwert

From NetHackWiki
(Redirected from Linux UTF8)
Jump to navigation Jump to search

It is possible to configure custom map symbols to arbitrary UTF8 characters using konwert. All that is required is to set each of the DUNGEON, TRAPS, EFFECTS, OBJECTS, and WARNINGS options to ASCII codes that are definitely not going to be used for any purpose other than drawing the map, then remap those values to the UTF8 characters you want.

Configuring NetHack

Turning on the eight_bit_tty option gives you access to character codes 128-255 which aren't otherwise used, so it's easiest just to set the various symbols to use those character codes, starting at 128:

DUNGEON=  128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 \
          144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 \
          160 161 162 163 164 165 166 167 168
TRAPS=                                        169 170 171 172 173 174 175 \
          176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
EFFECTS=                                                              191 \
          192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 \
          208 209 210 211 212 213 214 215 216 217 218 219
OBJECTS=                                                  220 221 222 223 \
          224 225 226 227 228 229 230 231 232 233 234 235 236
WARNINGS=                                                     237 238 239 \
          240 241 242

You may also want to set:

BOULDER = 243

So you can set different character for a statue and a boulder (233=\xE9 and 243=\xF3 in ˝/.konwert/aux/charsets/nethack, respectively). Otherwise, same character is used for both.

Configuring konwert

konwert filters are just executable shell scripts, and it will look for them in your ~/.konwert/filters/ directory. The cp437-UTF8 filter is a good starting-point, copy it into your personal filters directory from /usr/share/konwert/filters/cp437-UTF8. Edit it and remove the -e argument and the text that follows. Rename it 'nethack'. This filter looks for the character set conversion table ~/.konwert/aux/charsets/nethack - that is where you'll map the hexadecimal values of the character codes to actual UTF8 characters. Here's the file I'm using at the moment (I really should get around to specifying characters for those traps):

# DUNGEON
\x80 ⬚
\x81 ┃
\x82 ━
\x83 ┏
\x84 ┓
\x85 ┗
\x86 ┛
\x87 ╋
\x88 ┻
\x89 ┳
\x8A ┫
\x8B ┣
\x8C ▢
\x8D □
\x8E □
\x8F ▣
\x90 ▣
\x91 ▥
\x92 ♣
\x93 ·
\x94 ░
\x95 ▒
\x96 ⌫
\x97 ⌦
\x98 ⌊
\x99 ⌉
\x9A ✟
\x9B ∩
\x9C ♄
\x9D ◡
\x9E ∰
\x9F ⊚
\xA0 ☃
\xA1 ♨
\xA2 ╎
\xA3 ╌
\xA4 ╪
\xA5 ╫
\xA6 ≋
\xA7 ☁
\xA8 ≌
# TRAPS
\xA9 ^
\xAA ^
\xAB ^
\xAC ^
\xAD ^
\xAE ^
\xAF ^
\xB0 ^
\xB1 ^
\xB2 ^
\xB3 ^
\xB4 ^
\xB5 ^
\xB6 ^
\xB7 ^
\xB8 ^
\xB9 ^
\xBA "
\xBB ^
\xBC ^
\xBD ^
\xBE ^
# EFFECTS
\xBF │
\xC0 ─
\xC1 ╲
\xC2 ╱
\xC3 ☢
\xC4 ⚡
\xC5 ❯
\xC6 ❮
\xC7 ◴
\xC8 ◵
\xC9 ◶
\xCA ◷
\xCB ╭
\xCC ─
\xCD ╮
\xCE │
\xCF │
\xD0 ╰
\xD1 ─
\xD2 ╯
\xD3 ╲
\xD4 │
\xD5 ╱
\xD6 ─
\xD7 ╳
\xD8 ─
\xD9 ╱
\xDA │
\xDB ╲
# OBJECTS
\xDC ♅
\xDD ⚔
\xDE ◎
\xDF ◦
\xE0 ☿
\xE1 ☭
\xE2 ♋
\xE3 ⚱
\xE4 ♊
\xE5 ❐
\xE6 /
\xE7 $
\xE8 ♦
\xE9 ♜
\xEA ⚈
\xEB ☷
\xEC ✦
# WARNINGS
\xED ¹
\xEE ²
\xEF ³
\xF0 ⁴
\xF1 ⁵
\xF2 ⁶
# CUSTOM BOULDER
\xF3 ●

You can then place whatever UTF8 characters you want into the second column. If you're using complex pictorial characters like some of the ones I've chosen, it's worth configuring your terminal to use a large font when playing NetHack - I use Bitstream Vera Sans Mono at 19pt (as big as I can get it and still fit 80 columns on the screen).

Running NetHack

All that is left to do is run NetHack:

nethack | konwert nethack