From f90589bf59b0dc9efae90225aa5ec6efb603ba1f Mon Sep 17 00:00:00 2001 From: lijinwen Date: Wed, 24 Aug 2022 13:37:51 +0800 Subject: [PATCH] decode uri to utf-8 when use python2 --- fortls/jsonrpc.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fortls/jsonrpc.py b/fortls/jsonrpc.py index 9ffa65f..0ff5d0b 100644 --- a/fortls/jsonrpc.py +++ b/fortls/jsonrpc.py @@ -1,5 +1,6 @@ import json import logging +import sys try: import Queue except ImportError: @@ -17,6 +18,12 @@ def path_from_uri(uri): + #if python version is 2 , chinese uri path fail to identify + is_py2 = (sys.version_info[0] == 2) + if is_py2: + if isinstance(uri,unicode): + uri=uri.encode("utf-8") + # Convert file uri to path (strip html like head part) if not uri.startswith("file://"): return uri