diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index 46f85daba24..11c87e72d4e 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -997,17 +997,18 @@ dbus-string-to-byte-array STRING shall be UTF-8 coded." (if (zerop (length string)) '(:array :signature "y") - (cons :array (mapcan (lambda (c) (list :byte c)) string)))) + (cons :array + (mapcan (lambda (c) (list :byte c)) + (encode-coding-string string 'utf-8))))) -(defun dbus-byte-array-to-string (byte-array &optional multibyte) +(defun dbus-byte-array-to-string (byte-array &optional _multibyte) "Transform BYTE-ARRAY into UTF-8 coded string. -BYTE-ARRAY must be a list of structure (c1 c2 ...), or a byte -array as produced by `dbus-string-to-byte-array'. The resulting -string is unibyte encoded, unless MULTIBYTE is non-nil." - (apply - (if multibyte #'string #'unibyte-string) - (unless (equal byte-array '(:array :signature "y")) - (seq-filter #'characterp byte-array)))) +BYTE-ARRAY must be a unibyte list of structure (c1 c2 ...), or a byte +array as produced by `dbus-string-to-byte-array'." + (if-let ((bytes (seq-filter #'characterp byte-array)) + (string (apply #'unibyte-string bytes))) + (decode-coding-string string 'utf-8) + "")) (defun dbus-escape-as-identifier (string) "Escape an arbitrary STRING so it follows the rules for a C identifier.