F
F
fetch_girl2020-01-20 22:27:30
Python
fetch_girl, 2020-01-20 22:27:30

How to use Russian letters in a kv file?

I'm trying to parse a kv-file, but it contains the Russian alphabet and this causes an encoding error:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 143: character maps to <undefined>

What can be done about it?
Here is the code:
<Container_1>:
  orientation: 'vertical'
  padding: 50

  Button:
    size_hint: 0.5, 0.4
    pos_hint: {'center_x': 0.5, 'y': 0.1}
    text: 'История'
    font_size: 40
  Button:
    size_hint: 0.5, 0.4
    pos_hint: {'center_x': 0.5, 'y': 0.1}
    text: 'Провести диагностику'
    font_size: 40
    on_release:
      root.transition_1()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
o5a, 2020-01-21
@o5a

Specify the encoding explicitly.

with open("myfile.kv", encoding='utf8') as f:
    container = Builder.load_string(f.read())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question