Code: Select all
$ style.default.encoding = 'gb2312'
I have searched the forum and found that utf8 problem is an FAQ. I am using win98, if I want to convert my script to utf8 encoding one, I open it in IE- yes, internet explorer- then use the 'save as'. Since notepad in win98 does not support encoding, if I found something wrong with my script, I have to edit the original rpy file and launch IE again. It is tedious. Further more, my native tongue is Chinese. One Chinese characer takes up 2 chars in a no-encoding TXT, but 4 chars if it is in utf8, then the whole Ren'Py script needs more chars.
I can run this python statement in IDLE
Code: Select all
>>> sys.stdin.encoding
'cp936'
>>> codecs.utf_8_encode(u'汉字')
('\xc2\xba\xc2\xba\xc3\x97\xc3\x96', 4)
>>> hz='汉字'
>>> codecs.utf_8_encode(unicode(hz,sys.stdin.encoding))
('\xe6\xb1\x89\xe5\xad\x97', 2)
I try to change the current implement in Ren'Py by editing function list_logical_lines(filename) in parser.py
add
Code: Select all
import sys
import locale
change
Code: Select all
f = codecs.open(filename, "rU", "utf-8")
Code: Select all
f = codecs.open(filename, "rU")
change
Code: Select all
rv.append((filename, start_number, line))
Code: Select all
rv.append((filename, start_number, codecs.utf_8_encode(unicode(line,sys.stdin.encoding))[0]))
Code: Select all
rv.append((filename, start_number, codecs.utf_8_encode(unicode(line,locale.getdefaultlocale()[1]))[0]))
compile parser.py to parser.pyo and replace that renpy\parser.pyo in file lib\renpy.code
copy C:\Python23\Lib\encodings\*.pyo or overwrite encodings\*.pyo in file lib\renpy.code
however, when I run run_game.exe, it pops up with
Any idea?I'm sorry, but an exception occured while executing your Ren'Py
script.
LookupError: unknown encoding: cp936
While parsing game/script.rpy.
-- Full Traceback ------------------------------------------------------------
File "run_game.py", line 70, in main
File "renpy\main.pyo", line 161, in main
File "renpy\script.pyo", line 195, in load_script
File "renpy\script.pyo", line 87, in __init__
File "renpy\script.pyo", line 113, in load_file
File "C:\\renpy-5.0.1\lib\renpy.code\renpy\parser.py", line 1241, in parse
File "\renpy-5.0.1\lib\renpy.code\renpy\parser.py", line 107, in list_logical_lines
LookupError: unknown encoding: cp936
While parsing game/script.rpy.
Ren'Py Version: Ren'Py 5.0.1
2. How to use the default font(s) coming with OS without copying it to COMMON folder?
A Chinese font is big, normally 3~20M. Some fonts exist in all of the Chinese windows, for example, simfang.ttf(~4M). Can I set the following command to search the system font fold first? If there is no such a font file in {windows fold}\fonts, it then points to common\simfang.ttf. This is helpful in saving the space.
Code: Select all
$ style.default.font = "simfang.ttf"
Code: Select all
{font simfang}Hello{/font} {font symbol}world{/font}
4. Can I translate the moonlight.rpy into Chinese if I get the time?
Thank you.