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: Philipp Stephani
Subject: Re: [Emacs-diffs] master 93be35e: Fix encoding of JSON surrogate pairs
Date: Sun, 15 Jan 2017 20:34:27 +0000



Stefan Monnier <address@hidden> schrieb am So., 1. Jan. 2017 um 15:56 Uhr:
> +     ;; 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?

Maybe, I don't have a strong preference. The current solution avoids an additional nested conditional though. 

reply via email to

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