File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import sys
21import locale
32
4- try :
5- reload (sys )
6- except NameError : # Python 3
7- pass
3+ # Must stay in sync with the directory names in test-addon.js. Each name has
4+ # to be encodable in the code page it is keyed under: the MSVC toolchain
5+ # converts paths through the ANSI code page, so a name that only survives as
6+ # Unicode will fail to open at link time.
7+ TEXTMAP = {
8+ "cp936" : "文件夹" ,
9+ "cp1252" : "Latína" ,
10+ "cp932" : "フォルダ" ,
11+ }
812
913
1014def main ():
1115 encoding = locale .getdefaultlocale ()[1 ]
1216 if not encoding :
1317 return False
1418
19+ text = TEXTMAP .get (encoding )
20+ if text is None :
21+ return True
22+
1523 try :
16- sys .setdefaultencoding (encoding )
17- except AttributeError : # Python 3
18- pass
19-
20- textmap = {
21- "cp936" : "\u4e2d \u6587 " ,
22- "cp1252" : "Lat\u012b na" ,
23- "cp932" : "\u306b \u307b \u3093 \u3054 " ,
24- }
25- if encoding in textmap :
26- print (textmap [encoding ])
24+ text .encode (encoding )
25+ except UnicodeEncodeError :
26+ return False
27+
28+ print (text )
2729 return True
2830
2931
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ describe('addon', function () {
6868 // Select non-ascii characters by current encoding
6969 const testDirName = {
7070 cp936 : '文件夹' ,
71- cp1252 : 'Latīna ' ,
71+ cp1252 : 'Latína ' ,
7272 cp932 : 'フォルダ'
7373 } [ getEncoding ( ) ]
7474 // If encoding is UTF-8 or other then no need to test
You can’t perform that action at this time.
0 commit comments