@@ -263,4 +263,41 @@ function melee.getPlayerColor(port)
263
263
return PLAYER_COLORS [port ] or color_white
264
264
end
265
265
266
+ local char_replacement_map = {
267
+ [0x8149 ] = " !" , [0x8168 ] = " \" " , [0x8194 ] = " #" , [0x8190 ] = " $" ,
268
+ [0x8193 ] = " %" , [0x8195 ] = " &" , [0x8166 ] = " '" , [0x8169 ] = " (" ,
269
+ [0x816A ] = " )" , [0x8196 ] = " *" , [0x817B ] = " +" , [0x8143 ] = " ," ,
270
+ [0x817C ] = " -" , [0x8144 ] = " ." , [0x815E ] = " /" , [0x8146 ] = " :" ,
271
+ [0x8147 ] = " ;" , [0x8183 ] = " <" , [0x8181 ] = " =" , [0x8184 ] = " >" ,
272
+ [0x8148 ] = " ?" , [0x8197 ] = " @" , [0x816D ] = " [" , [0x815F ] = " \\ " ,
273
+ [0x816E ] = " ]" , [0x814F ] = " ^" , [0x8151 ] = " _" , [0x814D ] = " `" ,
274
+ [0x816F ] = " {" , [0x8162 ] = " |" , [0x8170 ] = " }" , [0x8160 ] = " ~" ,
275
+ }
276
+
277
+ function melee .convertStr (str )
278
+ local niceStr = " "
279
+ local i = 1
280
+ while i <= # str do
281
+ local c1 = string.sub (str , i , i )
282
+ local b1 = string.byte (c1 )
283
+
284
+ if bit .band (b1 , 0x80 ) == 0x80 then
285
+ local c2 = string.sub (str , i + 1 , i + 1 )
286
+ local b2 = string.byte (c2 )
287
+
288
+ local b16 = bit .bor (bit .lshift (b1 , 8 ), bit .lshift (b2 , 0 ))
289
+
290
+ if char_replacement_map [b16 ] then
291
+ niceStr = niceStr .. char_replacement_map [b16 ]
292
+ end
293
+
294
+ i = i + 2
295
+ else
296
+ niceStr = niceStr .. c1
297
+ i = i + 1
298
+ end
299
+ end
300
+ return niceStr
301
+ end
302
+
266
303
return melee
0 commit comments