Closed Kidwind closed 12 years ago
Your patch looks great, but I have one question about unicode(text, 'gbk', 'replace')
what exactly gkb
mean and what will it replace? I'm afraid if it can break other languages?
after your patch I'm unable to create any files utf-8 files/directories, not in Chinese, not in Russian and other non-ASCII languages, I'm using python 2.7 on linux
sorry,my english is not good. i Implementation supports multi-language is based os.listdir method Features, see : http://docs.python.org/library/os.html#os.listdir "Changed in version 2.3: On Windows NT/2k/XP and Unix, if path is a Unicode object, the result will be a list of Unicode objects. Undecodable filenames will still be returned as string objects."
so i change the _options parms "root" and "URL" to unicode encode:
self._options['URL'] = self.__toUtf8(self._options['URL'])
self._options['root'] = self.__toUtf8(self._options['root'])
but hashlib.md5().update(path) and extract/archive no support unicode string contain chinese character (may be any not ascii character). so i need revert to str,But when my unicode string contain chinese character, i can't use str(my_unicode_string) to revert, so i use __toByteStr method to revert. unicode method and encode method need a encode parm, so i pass 'gbk' (chinese encode).
in line 177:
field = 'targets[]'
if field in httpRequest:
self._request[field] = httpRequest.getlist(field)
may be only used in Django , Because Django's request object's get method only get last value when the key has more than one value. see : https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.QueryDict i'm not test in web2py, may be i need add Inspection like this:
if hasattr(httpRequest, 'getlist'):
field = 'targets[]'
if field in httpRequest:
self._request[field] = httpRequest.getlist(field)
hashlib.md5 unicode test:
import hashlib m = hashlib.md5() m.update('中国') m.update(u'中国') Traceback (most recent call last): File "
", line 1, in UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
About Django targets[]
: this should be fixed in connector.py or class, see https://github.com/Studio-42/elfinder-python/commit/0b320fd76da9280806b77a3db4645133456ae241
About unicode patches - I'm not ready to apply, it breaks Russian and other Europe languages. elFinder was designed to work with UTF-8
but not with full support of unicode, sorry.
But on my UTF-8 linux system I have no problem working with CJK, thought I do not know if it will work with GB2312 or GB18030
Test in Windows Platform,And Use in Django Web framework.