From 4288f92b467b453b0e5bb8e0ee9ce4521905c006 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 18 Jul 2024 16:16:53 +0200 Subject: [PATCH] Print non-ASCII chars in unibyte symbols as raw bytes 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 | 2 +- test/src/print-tests.el | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/print.c b/src/print.c index 138a21f18ab..c14e6e1419e 100644 --- a/src/print.c +++ b/src/print.c @@ -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) diff --git a/test/src/print-tests.el b/test/src/print-tests.el index ce8c095d496..c870427a0a9 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -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 -- 2.39.5