unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Philipp Stephani <p.stephani2@gmail.com>,
	Helmut Eller <eller.helmut@gmail.com>,
	24784@debbugs.gnu.org
Subject: bug#24784: 26.0.50; JSON strings with utf-16 escape codes
Date: Tue, 25 Oct 2016 02:19:18 +0300	[thread overview]
Message-ID: <63b3b672-f91c-f1b9-46e5-8f6dd8636714@yandex.ru> (raw)
In-Reply-To: <CAArVCkRcxSDgqL7r6zpz+B2DvCtAzpoNMiqnLxqnvXi=FUBGWA@mail.gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252; format=flowed, Size: 1270 bytes --]

Philipp,

Thanks. Some comments:

On 24.10.2016 22:57, Philipp Stephani wrote:

> +(defsubst json--decode-utf-16-surrogates (high low)

IIRC, there might be no actual benefit from making it a defsubst. If 
someone could benchmark it, I'd like to see the result.

> +     ;; Special-case UTF-16 surrogate pairs,
> +     ;; cf. https://tools.ietf.org/html/rfc7159#section-7
> +     ((looking-at
> +       (rx (group (any "Dd") (any "89ABab") (= 2 (any "0-9A-Fa-f")))
> +           "\\u" (group (any "Dd") (any "C-Fc-f") (= 2 (any "0-9A-Fa-f")))))
> +      (json-advance 10)
> +      (json--decode-utf-16-surrogates
> +       (string-to-number (match-string 1) 16)
> +       (string-to-number (match-string 2) 16)))

Shouldn't this go below the UTF-8 case, as the less-frequent one?

>  (ert-deftest test-json-encode-string ()
>    (should (equal (json-encode-string "foo") "\"foo\""))
>    (should (equal (json-encode-string "a\n\fb") "\"a\\n\\fb\""))
> -  (should (equal (json-encode-string "\nasdфыв\u001f\u007ffgh\t")
> -                 "\"\\nasdфыв\\u001f\u007ffgh\\t\"")))
> +  (should (equal (json-encode-string "\nasdфыв𝄞\u001f\u007ffgh\t")
> +                 "\"\\nasdфыв𝄞\\u001f\u007ffgh\\t\"")))

Why are we testing string encoding here?





  reply	other threads:[~2016-10-24 23:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 18:06 bug#24784: 26.0.50; JSON strings with utf-16 escape codes Helmut Eller
2016-10-24 19:57 ` Philipp Stephani
2016-10-24 23:19   ` Dmitry Gutov [this message]
2016-10-26 16:39     ` Helmut Eller
2016-10-26 17:37       ` Drew Adams
2016-12-31 16:53     ` Philipp Stephani
2017-01-01  0:45       ` Dmitry Gutov
2017-01-01 12:26         ` Philipp Stephani

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=63b3b672-f91c-f1b9-46e5-8f6dd8636714@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=24784@debbugs.gnu.org \
    --cc=eller.helmut@gmail.com \
    --cc=p.stephani2@gmail.com \
    /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).