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

Environment variable LANG #435

Closed
randy3k opened this issue Jun 6, 2021 · 2 comments · Fixed by #436
Closed

Environment variable LANG #435

randy3k opened this issue Jun 6, 2021 · 2 comments · Fixed by #436

Comments

@randy3k
Copy link
Member

randy3k commented Jun 6, 2021

Recently, I notice that languageserver fails in some subtle way when the LANG variable is not set.
More precisely, the json returns by the server will be garbled if it contains any non-ascii chars.

It is caused by the fact that R will dump non-ascii chars in their literal form. It causes a dismatch in their number of bytes of the json and the calculated length of the json message.

(=)-~$ Rscript -e "cat('\U2018\n')"
‘
(=)-~$ LANG= Rscript -e "cat('\U2018\n')"
<U+2018>

I observed this bug in the recent version of languageserver when I am hovering on some text on Sublime Text and the doc rendered by html_to_markdown contains the char . It is particularly an issue of Sublime Text because the variable LANG is not set in default.

Any suggestion on how to handle it? It could be an ongoing reason of issues.

@randy3k
Copy link
Member Author

randy3k commented Jun 6, 2021

I haven't checked how it affects Windows users. But I assume that the special treatment has already handled it.

@randy3k
Copy link
Member Author

randy3k commented Jun 6, 2021

One solution is to check on unix system that isTRUE(l10n_info()[["UTF-8"]]) and warn user to set the LANG variable. Another solution is to always use

writeLines(text, self$outputcon, sep = "", useBytes = TRUE)

as what we have done on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant