]> git.eshelyaron.com Git - emacs.git/commitdiff
Print non-ASCII chars in unibyte symbols as raw bytes
authorMattias EngdegÄrd <mattiase@acm.org>
Thu, 18 Jul 2024 14:16:53 +0000 (16:16 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 07:48:29 +0000 (09:48 +0200)
Previously, latin-1 was incorrectly assumed (bug#70988).

* src/print.c (print_object): Call the correct function.
* test/src/print-tests.el (print-unibyte-symbols): New test.

(cherry picked from commit f2f76756211fd5a0914734c738508f522c4b2ccd)

src/print.c
test/src/print-tests.el

index 138a21f18ab3ff1c61f5e91ad0c78b5a411d5a21..c14e6e1419e3e7d1ba0cbcb0151fd6f0d4ccb5c6 100644 (file)
@@ -2475,7 +2475,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
          {
            /* Here, we must convert each multi-byte form to the
               corresponding character code before handing it to PRINTCHAR.  */
-           int c = fetch_string_char_advance (name, &i, &i_byte);
+           int c = fetch_string_char_as_multibyte_advance (name, &i, &i_byte);
            maybe_quit ();
 
            if (escapeflag)
index ce8c095d496004fd87a3827445df0ccc64bba4e4..c870427a0a90ca4210527824d239b0646643556a 100644 (file)
@@ -560,5 +560,12 @@ otherwise, use a different charset."
              (ignore (make-string 100 ?b))))
     (should (equal outstr "xxx"))))
 
+(ert-deftest print-unibyte-symbols ()
+  ;; Non-ASCII in unibyte symbols should print as raw bytes.
+  (should (equal (prin1-to-string (make-symbol "a\xff"))
+                 (string-to-multibyte "a\xff")))
+  (should (equal (prin1-to-string (make-symbol "th\303\251"))
+                 (string-to-multibyte "th\303\251"))))
+
 (provide 'print-tests)
 ;;; print-tests.el ends here