I have a problem problems with non-ASCII characters(russian languge). I use
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import sfml as sf
import json
class draws:
def __init__(self):
with open('setting.json') as data_file:
setting = json.load(data_file)
print
self.window = sf.RenderWindow(sf.VideoMode(setting['window_width'],
setting['window_height']),
setting['title'])
self.run()#bot
def run(self):
font = sf.Font.from_file("arial.ttf")
text = sf.Text("Русский текст", font, 16)#this error string
while self.window.is_open:
for event in self.window.events:
if type(event) is sf.CloseEvent:
self.window.close()
self.window.clear(sf.Color.BLUE)
self.window.draw(text)
self.window.display()
if __name__ == "__main__":
Tree = draws()
but i get error:
Console error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)I use unicode:
text = sf.Text(u"Русский текст", font, 16)#this error string
exelent, but wrong drawing literals. image error:
I use cp1253(russian decode)
text = sf.Text(u"Русский текст".decode('cp1253'), font, 16)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordin al not in range(128)
i use python 2.7 and pysfml 2.2 in exe installer
English text exelent draw. I now not see as this job.
You redactor replacement code, this link pastebin:
http://pastebin.com/nw04s6Cahttp://pastebin.com/Tyfae3RC