Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError #1187

Closed
DoctorChe opened this issue Dec 3, 2017 · 3 comments
Closed

UnicodeDecodeError #1187

DoctorChe opened this issue Dec 3, 2017 · 3 comments

Comments

@DoctorChe
Copy link

Hi,

I'm trying to use Cyrillic in the interface, but app does not start. Here is the code:

main.py

#  -*- coding: utf-8 -*-

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

class MainScreen(Screen):
    pass

class AnotherScreen(Screen):
    pass

class ScreenManagement(ScreenManager):
    pass

presentation = Builder.load_file("main.kv")

class MainApp(App):
    def build(self):
        return presentation

MainApp().run()

main.kv

#  -*- coding: utf-8 -*-

ScreenManagement:
    MainScreen:
    AnotherScreen:

<MainScreen>:
    name: 'main'

    Button:
        on_release: app.root.current = 'other'
        text: 'Другой экран'
        font_size: 50

<AnotherScreen>:
    name: 'other'

    Button:
        on_release: app.root.current = 'main'
        text: 'back to the home screen'
        font_size: 50

When I run the program on Android, I got:

[INFO ] [Logger ] Record log in /storage/emulated/0/Download/TrafficTaxApp/TrafficTaxApp/.kivy/logs/kivy_17-12-03_2.txt
[INFO ] [Kivy ] v1.9.2-dev0
[INFO ] [Python ] v3.6.2 (default, Oct 29 2017, 05:27:57)
[GCC 7.2.0]
[INFO ] [Factory ] 193 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
Traceback (most recent call last):
File "/storage/emulated/0/Download/TrafficTaxApp/TrafficTaxApp/main.py", line 19, in
presentation = Builder.load_file("main.kv")
File "/data/data/ru.iiec.pydroid3/files/i686-linux-android/lib/python3.6/site-packages/kivy/lang/builder.py", line 290, in load_file
data = fd.read()
File "/data/data/ru.iiec.pydroid3/files/i686-linux-android/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 186: ordinal not in range(128)

On Ubuntu, everything is good.

Any idea on this?

@inclement
Copy link
Member

I think there's a known issue with the kv decoding codec on Android, where it defaults to ascii rather than utf-8. A workaround is to remove the non-ascii characters from the kv code and set (or at least import) them from the python code.

@KeyWeeUsr
Copy link
Contributor

ref kivy/kivy#4003

@inclement
Copy link
Member

Thanks @KeyWeeUsr , closing as a duplicate of kivy/kivy#4003.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants