unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Felix Weilbach <felix.weilbach@t-online.de>
Cc: emacs-devel@gnu.org
Subject: Re: JSON parsing of Extended ASCII
Date: Tue, 10 May 2022 20:30:48 +0300	[thread overview]
Message-ID: <83fslhs3av.fsf@gnu.org> (raw)
In-Reply-To: <4763d841-54f0-d146-d968-beb7988431ff@t-online.de> (message from Felix Weilbach on Tue, 10 May 2022 19:18:37 +0200)

> Date: Tue, 10 May 2022 19:18:37 +0200
> From: Felix Weilbach <felix.weilbach@t-online.de>
> 
> I'm working on source code that has Extended ASCII characters inside 
> comments in it.

What do you mean by "Extended ASCII"?  Is this some encoding different
from UTF-8, like Latin-1 or Windows codepage 1251?  Or is it something
else?

> This is unfortunate because LSP-mode crashes if it 
> encounters an invalid UTF-8 string. I know this mailing list is not 
> about LSP-mode, but I could track down the issue to the function 
> json_stringn() that gets called in lisp_to_json() inside json.c. Visual 
> Studio Code can cope with these files fine and their LSP implementation 
> has no problem with these files. Therefore I think Emacs should handle 
> this situation as well. I want to find a solution to this problem and 
> implement it. What do you think about this problem? Have you ideas for a 
> solution? Should a potential solution be implemented inside Emacs or 
> LSP-mode?
> 
> I think there could be implemented a function inside Emacs that tries to 
> convert Extended ASCII to UTF-8 and then encodes it to JSON.

Strings held inside Emacs are stored in (a superset of) UTF-8 anyway,
so this problem should not exist for you.  IOW, the conversion to
UTF-8 is done automatically when non-ASCII string is read into Emacs.
So I think you should provide more details about your use case
specifics, because it is likely that the problem is not where you
think it is.

In any case, Emacs and json.c require UTF-8 because that's what
libjansson, the library we use for JSON parsing, enforces.  It won't
help if we pass non-UTF-8 strings to the library, because it won't
work.



  reply	other threads:[~2022-05-10 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 17:18 JSON parsing of Extended ASCII Felix Weilbach
2022-05-10 17:30 ` Eli Zaretskii [this message]
2022-05-10 17:50 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fslhs3av.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=felix.weilbach@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).