简体   繁体   中英

pygame ang non-latin chars issue

I've got such problem - when I pressing keyboard button in russian layout my application crushes with such message

UnicodeEncodeError: 'ascii' codec can't encode character '\ф' in position 40: ordinal not in range(128)

code:

 event = pygame.event.poll()
 if event.type == KEYDOWN:
    print(event)

(I've pressed latin 'a') Pressing keys on English layout - works fine.

By the way - when I'm changing event.type == KEYDOWN to event.type == KEYUP - everything works, but in thi case I cannot access event.unicode param to get pressed key

Can some one advise me how to make it working with any keyboard layout KeyDown events?

Thanks!

尝试在文件开头添加以下行:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM