Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3, Path has Chinese text don't work #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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