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

Fail to parse source files that are encoded in zh_CN.GBK #1458

Closed
caterchong opened this issue Apr 15, 2015 · 9 comments
Closed

Fail to parse source files that are encoded in zh_CN.GBK #1458

caterchong opened this issue Apr 15, 2015 · 9 comments

Comments

@caterchong
Copy link

The time I run the command":YcmDiags", errors below will show up. Can I change the default decoder? Thanks very much.

UnicodeDecodeError: 'utf8' codec can't decode byte 0xcd in position 0: invalid continuation byte
Traceback (most recent call last):
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 861, in _handle
return route.call(*_args)
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1734, in wrapper
rv = callback(_a, *_ka)
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 100, in wrapper
return callback( *args, *_kwargs )
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/hmac_plugin.py", line 54, in wrapper
body = callback( _args, *_kwargs )
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 58, in EventNotification
request_data = RequestWrap( request.json )
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 182, in get
if key not in storage: storage[key] = self.getter(obj)
File "/home/cater/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1125, in json
return json_loads(self._get_body_string())
File "/usr/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xcd in position 0: invalid continuation byte

@vheon
Copy link
Contributor

vheon commented Apr 15, 2015

Can you post a simple test case?

@caterchong
Copy link
Author

an sample code will do.
//测试
struct mystruct
{ int a ;}

int main()
{
struct mystruct hello;
hello.a=10; // no auto complete here
return 0;
}

When you copy the sample code to your workspace, make sure that the Chinese comments at the first line are encoded in GBK. iconv -f utf-8 -t gbk may help.

Thanks for helping.

@vheon
Copy link
Contributor

vheon commented Apr 15, 2015

I think that this is a duplicate of ycm-core/ycmd#109

@vheon vheon closed this as completed Apr 15, 2015
@vheon
Copy link
Contributor

vheon commented Apr 15, 2015

If you think It's not a duplicate, let me know.

@caterchong
Copy link
Author

I am not so familiar to git. I guess that my problem is a duplicate. It seems that this bug has been fixed. So I only need to update to the newest version?

@vheon
Copy link
Contributor

vheon commented Apr 15, 2015

@caterchong It is not fixed yet, but to me it seems that it has been already reported to the ycmd project. So you don't get any completion at all when you have unicode characters in your comments?

@caterchong
Copy link
Author

The completion works fine if the source code is encoding in utf-8 format. When I revert the source files to GBK encoding, it never works right.

@vheon
Copy link
Contributor

vheon commented Apr 15, 2015

It is known at the moment that YCM do not work at its best with unicode. I don't know what is the expected behaviour in this case, so I'll reopen this and let @Valloric tell you what it should be.

@vheon vheon reopened this Apr 15, 2015
@Valloric
Copy link
Member

Your encoding in Vim should be utf8; other encodings are not supported. They might or might not work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants