Function: parseclj-lex--string-value

parseclj-lex--string-value is a byte-compiled function defined in parseclj-lex.el.

Signature

(parseclj-lex--string-value S)

Documentation

Parse an EDN string S into a regular string.

S goes through three transformations:
- Escaped characters in S are transformed into Elisp escaped
  characters.
- Unicode escaped characters are decoded into its corresponding
  unicode character counterpart.
- Octal escaped characters are decoded into its corresponding
  character counterpart.

Source Code

;; Defined in ~/.emacs.d/elpa/parseclj-20231203.1905/parseclj-lex.el
;; Elisp values from tokens

(defun parseclj-lex--string-value (s)
  "Parse an EDN string S into a regular string.
S goes through three transformations:
- Escaped characters in S are transformed into Elisp escaped
  characters.
- Unicode escaped characters are decoded into its corresponding
  unicode character counterpart.
- Octal escaped characters are decoded into its corresponding
  character counterpart."
  (replace-regexp-in-string
   "\\\\o[0-8]\\{3\\}"
   (lambda (x)
     (make-string 1 (string-to-number (substring x 2) 8)))
   (replace-regexp-in-string
    "\\\\u[0-9a-fA-F]\\{4\\}"
    (lambda (x)
      (make-string 1 (string-to-number (substring x 2) 16)))
    (replace-regexp-in-string "\\\\[tbnrf'\"\\]"
                              (lambda (x)
                                (let ((ch (elt x 1)))
                                  (cond
                                   ((eq ?t ch) "\t")
                                   ((eq ?f ch) "\f")
                                   ((eq ?\" ch) "\"")
                                   ((eq ?r ch) "\r")
                                   ((eq ?n ch) "\n")
                                   ((eq ?\\ ch) "\\\\")
                                   (t (substring x 1)))))
                              (substring s 1 -1)))))