reddit / emacs

charset issue with emacs-w3m

J-ky · 2022-06-16 13:46
I am experiencing a very weird bug with emacs-w3m. When I visit duckduckgo, the return page is a bunch of non-sense encoding char. I have no idea what charset or encoding the page is at. The strangest thing is that, I have no problem visiting every other site, only duckduckgo is affected. I tried to pop up a terminal, and use w3m to visit duckduckgo, no problem. I tested the same emacs config on my macbook, the same version of w3m and emacs-w3m, no problem. Here is what it looks like when I use \`w3m-download\` to download the bugged page. The url I opened is [https://lite.duckduckgo.com/lite](https://lite.duckduckgo.com/lite). [https://gist.github.com/drshapeless/d8eb40adbaf1cc00ba914a36958deb6b](https://gist.github.com/drshapeless/d8eb40adbaf1cc00ba914a36958deb6b) I am using Arch Linux, w3m is installed via AUR. I can load the correct html of duckduckgo via curl or firefox. I even tried to download the html to a local file and ask emacs-w3m to open the file. No problem. Duckduckgo is broken when I directly visit it in emacs-w3m.
lwj786 · 2022-11-14 13:43
I have a same/similar problem. And I find the problem is related to `Content-Encoding`, when using `w3m -dump_both url`, the output shows it's encoding in header is `Content-Encoding: br`. So after checking the source code and some trying, it works again. Just add following code to the `~/.emacs-w3m.el`: ``` (setq w3m-encoding-alist (nconc w3m-encoding-alist '(("br" . brotli)))) (setq w3m-decoder-alist (nconc w3m-decoder-alist '((brotli "brotli" ("-d"))))) ``` Hope this works for you too.
lwj786 · 2022-11-15 14:19
Oh, upstream has [support it](https://github.com/emacs-w3m/emacs-w3m/commit/ceb4650af76bb94f1f9dbcaab8871909c7857b55) recently.