chinese path or filename supported
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zim |
Fix Released
|
High
|
Unassigned |
Bug Description
I am using zim v0.46 on Windows.
== the zim on my Chinese Windows OS can't running correctly with some errors :
* zim can't run in a path with Chinese character. It will return "UnicodeDecodeE
* it can't create a note with Chinese page name.
* it can't attach a image or other attachment from Chinese named folders.
And the errors disappeared after I modified some source code.
I try to check the code and maybe find the problem.In Chinese Windows OS we can't directly use the following code for a path:
unicode(path, 'utf-8')
or
path.encode(
but the following is correct:
unicode(path, 'gb2312')
if using the following code, it maybe support Korean or Japanese.
unicode(path, sys.getfilesyst
* line 388 in zim/fs.py
class WindowsPath(
...
def _abspath(path):
...
# return os.path.
# my fixed code
path = os.path.
if isinstance(path, unicode) :
return path
else :
return unicode(path, sys.getfilesyst
* before class UnixPath in zim/fs.py
# my added code
def tryUnicode(path):
if isinstance(path, unicode) :
return path
elif isinstance(path, Dir) :
return unicode(path)
else :
return unicode(path, sys.getfilesyst
* line 191 in zim/fs.py
class UnixPath(object):
...
def __init__(self, path):
...
# path = map(unicode, path) # original code
# my fixed code
path = map(tryUnicode, path)
so that all path are ready unicode in Windows
* line 166 in zim/fs.py
def isdir(path):
# return os.path.
# my fixed code
return os.path.isdir(path)
def isfile(path):
# return os.path.
# my fixed code
return os.path.
* line 275 in zim/fs.py
def iswritable(self):
...
# return os.access(
# my fixed code
return os.access(
* line 40 in zim.py
# argv = [arg.decode(
# my fixed code.I think it is not need to decode in Windows.
argv = [arg for arg in sys.argv]
* line 69 in zim/applications.py
def _checkargs(self, cwd, args):
...
# argv = [a.encode('utf-8') for a in self._cmd(args)] # original code
# my fixed code
argv = [a for a in self._cmd(args)]
# if cwd: # original code
# cwd = unicode(
return cwd, argv
* line 1021 in zim/gui/widgets.py
def get_file(self):
...
# else: return File(path) # original code
# my fixed code. it fix the file name string that GTK returned to unicode.
else: return File(path.
On Sat, 2010-05-01 at 05:54 +0000, aosp wrote: rror: 'ascii' codec can't decode byte 0xd6 in position 3: ordinal not in range(128)" at launch. 'utf-8' ) emencoding( ))
> == the zim on my Chinese Windows OS can't running correctly with some errors :
> * zim can't run in a path with Chinese character. It will return "UnicodeDecodeE
> * it can't create a note with Chinese page name.
> * it can't attach a image or other attachment from Chinese named folders.
>
> And the errors disappeared after I modified some source code.
>
> I try to check the code and maybe find the problem.In Chinese Windows OS we can't directly use the following code for a path:
> unicode(path, 'utf-8')
> or
> path.encode(
>
> but the following is correct:
> unicode(path, 'gb2312')
>
> if using the following code, it maybe support Korean or Japanese.
> unicode(path, sys.getfilesyst
This looks like a good fix, will include it. Only question is whether we
need to have compatibility mode for current users. Really need to be
sure this does not break anything for current users.
Regards,
Jaap