emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master 93be35e: Fix encoding of JSON surrogate pairs


From: Stefan Monnier
Subject: Re: [Emacs-diffs] master 93be35e: Fix encoding of JSON surrogate pairs
Date: Sun, 01 Jan 2017 09:55:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> +     ;; Special-case UTF-16 surrogate pairs,
> +     ;; cf. https://tools.ietf.org/html/rfc7159#section-7.  Note that
> +     ;; this clause overlaps with the next one and therefore has to
> +     ;; come first.
> +     ((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)))
>       ((looking-at "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]")

Wouldn't it be better to move the surrogate-handling into the
hex-handling branch?


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]