transmission icon indicating copy to clipboard operation
transmission copied to clipboard

multibyte for unicode strings

Open tamwile opened this issue 2 years ago • 3 comments

When i have a torrent in my list with non ascii characters, they are represented as escaped unicode \xxx

The enable-multibyte-characters variable is set to true, so this shouldn't happen. Here is a hack to circumvent it in the meantime: Calling (set-buffer-multibyte t) doesn't work, we first need to (set-buffer-multibyte nil) and then to (set-buffer-multibyte t). Or alternatively, to call (toggle-enable-multibyte-characters) twice.

I can reproduce it with emacs -Q and emacs -nw.

At the beginning, i thought it was a bug in emacs, but proced works correctly with processes having non ascii chars.

transmission-draw-torrents seems to return the escaped version of strings, but when calling transmission-remote from the terminal, it works and renders correctly.

Can someone tell me if the error is in transmission or transmission.el, and possibly fix it ?

tamwile avatar Dec 26 '23 06:12 tamwile

I just upgraded from Ubuntu LTS 22.04 to 22.04.1 today. In the process I upgraded transmission from 3.00 to 4.0.5. I compile emacs (28) from source separately so it was not altered in the upgrade. I now have the issue exactly as you describe above, it was working as intended for the end user prior to this upgrade. I suspect it is a transmission problem although I am too lazy to dig deeper. Something related to transmission RPC maybe. Note, I have not yet downgraded back to 3.00 for confirmation that this is exactly where the problem is.

stvlm6 avatar Aug 31 '24 09:08 stvlm6

Yes, that was also my conclusion. iirc, i think i have read an issue in the transmission repo saying they are now using a lib to handle unicode. The cli tools from the transmission project are working because they probably have been adapted.

I guess someone with some elisp knowledge could try to make a pull request to follow this breaking change of transmission.

In the meantime, i use this dirty trick:

(defun transmission-hack-multibyte ()
  "Circumvent multibyte bug with transmission.el"
  (interactive)
  (revert-buffer)
  (toggle-enable-multibyte-characters)
  (toggle-enable-multibyte-characters)
  )

And i bind g to this function instead of the default.

tamwile avatar Sep 02 '24 03:09 tamwile

Dirty trick applied to transmission.el since I like the auto refresh.

(defun transmission-timer-revert ()
  "Revert the buffer or cancel `transmission-timer'."
  (if (and (memq major-mode transmission-refresh-modes)
           (not (or (bound-and-true-p isearch-mode)
                    (buffer-narrowed-p)
                    (use-region-p))))
    (progn
      (revert-buffer)
      (set-buffer-multibyte nil)
      (set-buffer-multibyte t))
    (cancel-timer transmission-timer)))

stvlm6 avatar Sep 02 '24 04:09 stvlm6

My trick is to change 'binary to 'utf-8-unix in transmission-make-network-process: https://github.com/holomorph/transmission/blob/master/transmission.el#L450

whhone avatar Dec 07 '24 20:12 whhone

Not sure why I set :coding 'binary and :filter-multibyte, it looks like the RPC spec prescribes UTF-8 coding all the way back to transmission versions 1.x. Changing to UTF-8 coding appears to work fine on current transmission versions and 2.9x on a debian image I have. Will fix

holomorph avatar May 22 '25 14:05 holomorph

Fixed in ae36637fe

holomorph avatar May 24 '25 03:05 holomorph