SethBling / cbscript

CBScript for Minecraft
1.14k stars 27 forks source link

Cyrillic is not supported #9

Open DedMaxim opened 6 months ago

DedMaxim commented 6 months ago

As said in title, Cyrillic is not supported. Trying to compile a script with Cyrillic letters throws following error:

Compiler encountered unexpected error during compilation:
Traceback (most recent call last):
  File "E:\Program Files\CBScript\cbscript.py", line 70, in try_to_compile
    success = self.compile_all()
  File "E:\Program Files\CBScript\cbscript.py", line 134, in compile_all
    world.write_functions(self.global_context.functions)
  File "E:\Program Files\CBScript\mcworld.py", line 33, in write_functions
    text = func.get_utf8_text()
  File "E:\Program Files\CBScript\mcfunction.py", line 434, in get_utf8_text
    return "\n".join([(cmd if cmd[0] != '/' else cmd[1:]) for cmd in self.commands]).encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 104: ordinal not in range(128)

Script is simple:

dir "C:\Users\Max\Desktop\Alcore Impact Server\world"
desc "A datapack that tells dialog lines"

import common

reset
end

function test1()
    /execute positioned -222.66 98.00 -157.52 run execute at @a[distance=..5] run tellraw @a {"text":"[Mage] ыдвлаожфдвлоа!"}
end

As a workaround, Cyrillic letters can be converted to Java entities through web translators like this one http://www.itpro.cz/juniconv/ But it's not as convenient as being able to actually see letters in the script