From: Benny M. <ben...@gm...> - 2010-02-16 15:41:20
|
2010/2/16 Peter Landgren <pet...@te...>: > Didn't finish last mail. >> <snip> >> >> > > import const >> > > print "After import const:", type(const.PLUGINS_DIR), const.PLUGINS_DIR >> > > for qaz in const.__dict__.keys(): print type(qaz), qaz >> > >> > This is wrong, qaz is the key, not the value of the dict[key]! It is >> > normal result is str. >> >> Yes, I realized that after I sent the mail! >> However, it let me to look at the values() instead. Then I noticed that >> some of the path constants were 'str' while some other unicode: >> >> Def of ROOT_DIR: <type 'unicode'> C:\Documents and Settings\Pär\Mina >> dokument\gramps320 Def of HOME_DIR: <type 'str'> C:\Documents and >> Settings\Põr\Application Data\gramps After import const ROOT_DIR: <type >> 'unicode'> C:\Documents and Settings\P"r\Mina dokument\gramps320 After >> import const HOME_DIR: <type 'str'> C:\Documents and >> Settings\Pär\Application Data\gramps >> >> See how Pär has three different "spellings". >> If I scan the three different strings I found that "ä" always has the ord() >> value of 228. >> >> > Unicode is not an encoding, so you could try to encode the string to >> > utf-8, and then you know in const.py, value of PLUGINS_DIR is an utf-8 >> > encoded string. So you would add an encode, to get 'utf-8' for sure. >> > > Def of ROOT_DIR: <type 'unicode'> C:\Documents and Settings\Pär\Mina dokument\gramps320 > Def of HOME_DIR: <type 'str'> C:\Documents and Settings\Põr\Application Data\gramps > After import const ROOT_DIR: <type 'unicode'> C:\Documents and Settings\P"r\Mina > dokument\gramps320 > After import const HOME_DIR: <type 'str'> C:\Documents and Settings\Pär\Application Data\gramps > > Using print repr(): > ROOT_DIR= u'C:\\Documents and Settings\\P\xe4r\\Mina dokument\\gramps320' > HOME_DIR= 'C:\\Documents and Settings\\P\xe4r\\Application Data\\gramps' > > isn't the problem that "ä" is represented by the same code in both a unicode and a 'str' string? > Yes, HOME_DIR and USER_HOME should also be unicode, just as ROOT_DIR. That will not fix any problems with plugins dir, as that derives from ROOT_DIR. It could cause problems elsewhere though. Benny > /Peter > > |