Skip to content

Commit

Permalink
Fix emmetio#3, Path has Chinese text don't work
Browse files Browse the repository at this point in the history
  • Loading branch information
laoshu133 committed Mar 14, 2014
1 parent 0c032c0 commit 4c49fb7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions EmmetNPP/emmet/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ def read_file(path, size=-1, mode='rb'):
with open(path, mode, **kwargs) as fp:
return fp.read(size)

def unicode_str_isneed(str, encoding='utf-8'):
if not isinstance(str, unicode):
str = unicode(str, encoding)

return str


class File():
def __init__(self):
pass

def _read(self, path, size, mode='rb'):
path = unicode_str_isneed(path)
reader = is_url(path) and read_http or read_file
return reader(path, size, mode)

Expand Down Expand Up @@ -93,6 +101,9 @@ def locate_file(self, editor_file, file_name):

result = None

editor_file = unicode_str_isneed(editor_file)
file_name = unicode_str_isneed(file_name)

previous_parent = ''
parent = os.path.dirname(editor_file)
while parent and os.path.exists(parent) and parent != previous_parent:
Expand Down

0 comments on commit 4c49fb7

Please sign in to comment.