Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[lsp4e-dev] Character encoding of requests?

Hi,

I'm working on an LSP server implementation, and using lsp4e and vscode as test clients.

I've just tried entering text at the client with non-ASCII characters. It looks as though *both* lsp4e and vscode send the JSON didChange message as cp1252 encoding, even though I'm on Linux with a default encoding of UTF-8, though neither implementation include a Content-Type header. As I read the spec, this should default to UTF8? Also, curiously, the Content-Length *still* seems to be wrong, even allowing for cp1252 encoding. It usually gives a length that is one too large. See below.

Has anyone else had experience with this?

For example sending a single pound character:

Content-Length: 285
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":2,"uri":"file:///home/nick/eclipse.overture/LSP%20Project/test1.vdmsl"},"contentChanges":[{"range":{"start":{"line":13,"character":6},"end":{"line":13,"character":6}},"rangeLength":0,"text":"£"}]}}C

But there are only 284 *bytes* (also characters), since in cp1252 a £ sign is a single byte (A3). So you can see the "C" on the end, which is part of the next message header!

Cheers,
-nick

Back to the top