Chinese unicode fonts in PyGame

pygame uses SDL_ttf for rendering, so you should be in fine shape as rendering goes. unifont.org appears to have some extensive resources on Open-Source fonts for a range of scripts. I grabbed the Cyberbit pan-unicode font and extracted the encluded ttf. The folowing ‘worked on my machine’ which is a Windows Vista Home Basic and … Read more

Flutter fetched Japanese character from server decoded wrong

If you look in postman, you will probably see that the Content-Type http header sent by the server is missing the encoding tag. This causes the Dart http client to decode the body as Latin-1 instead of utf-8. There’s a simple workaround: http.Response response = await http.get(‘SOME URL’,headers: {‘Content-Type’: ‘application/json’}); List<dynamic> responseJson = json.decode(utf8.decode(response.bodyBytes));

Find all Chinese text in a string using Python and Regex

Python 2: #!/usr/bin/env python # -*- encoding: utf8 -*- import re sample = u’I am from 美国。We should be friends. 朋友。’ for n in re.findall(ur'[\u4e00-\u9fff]+’,sample): print n Python 3: sample=”I am from 美国。We should be friends. 朋友。” for n in re.findall(r'[\u4e00-\u9fff]+’, sample): print(n) Output: 美国 朋友 About Unicode code blocks: The 4E00—9FFF range covers CJK … Read more