emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/emms f9f2bab 30/80: Trim trailing whitespace from id3v2


From: Stefan Monnier
Subject: [elpa] externals/emms f9f2bab 30/80: Trim trailing whitespace from id3v2 strings
Date: Wed, 17 Mar 2021 18:42:24 -0400 (EDT)

branch: externals/emms
commit f9f2bab6acc2b078f1b0031f2c626b8f3dfbdbd0
Author: Petteri Hintsanen <petterih@iki.fi>
Commit: Petteri Hintsanen <petterih@iki.fi>

    Trim trailing whitespace from id3v2 strings
---
 emms-info-native.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/emms-info-native.el b/emms-info-native.el
index bca21b1..4aaafed 100644
--- a/emms-info-native.el
+++ b/emms-info-native.el
@@ -728,15 +728,17 @@ If there is no such identifier, return nil."
 
 (defun emms-info-native--decode-id3v2-string (bytes)
   "Decode id3v2 text information from BYTES.
-Remove the terminating null byte, if any.  Return the text as
-string."
+Remove the terminating null byte, if any, and trim trailing
+whitespace.
+
+Return the text as string."
   (let* ((encoding (emms-info-native--id3v2-text-encoding bytes))
          (string (mapconcat #'byte-to-string (seq-rest bytes) ""))
          (decoded (decode-coding-string string encoding)))
     (when (> (length decoded) 0)
-      (if (equal (substring decoded -1) "\0")
-          (substring decoded 0 -1)
-        decoded))))
+      (string-trim-right (if (equal (substring decoded -1) "\0")
+                             (substring decoded 0 -1)
+                           decoded)))))
 
 (defun emms-info-native--id3v2-text-encoding (bytes)
   "Return the encoding for text information BYTES."



reply via email to

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