Groups | Search | Server Info | Login | Register


Groups > comp.emacs > #2523

Re: Fixing Garbled Encodings

From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.emacs
Subject Re: Fixing Garbled Encodings
Date 2026-02-24 01:55 +0000
Organization A noiseless patient Spider
Message-ID <10nj0eh$3g050$1@dont-email.me> (permalink)
References <10mrmnj$3obvm$4@dont-email.me> <slrn10p5r9v.42g2.jcb@kotte.inf.ed.ac.uk> <10n0olg$1erpn$1@dont-email.me> <slrn10p932m.5h9c.jcb@kotte.inf.ed.ac.uk>

Show all headers | View raw


On Tue, 17 Feb 2026 15:42:14 -0000 (UTC), Julian Bradfield wrote:

> Try this:
>
> (defun utf8decode ()
>   "Decode the region as utf-8. Mainly for doubly encoded emails."
>   (interactive)
>   (kill-region 0 0 t)
>   (let ((mybuf (current-buffer)))
>     (with-temp-buffer
>       (set-buffer-multibyte nil)
>       (yank)
>       (decode-coding-region 1 (point-max) 'utf-8 mybuf)))
>   )

Yes, that works, thanks. I was able to get this to work as well:

    (defun utf8_ungarble (beg end)
        "tries to decode the selection as garbled UTF-8 encoding."
        (interactive "*r")
        (let*
            (
                (prevbuf (current-buffer))
                (the-text (delete-and-extract-region beg end))
            )
            (with-temp-buffer
                (set-buffer-multibyte nil)
                (insert the-text)
                (decode-coding-region (point-min) (point-max) 'utf-8 prevbuf)
            ) ; with-temp-buffer
        ) ; let
    ) ; utf8_ungarble

Back to comp.emacs | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-15 05:48 +0000
  Re: Fixing Garbled Encodings Julian Bradfield <jcb@inf.ed.ac.uk> - 2026-02-16 10:11 +0000
    Re: Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-16 20:35 +0000
    Re: Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-17 03:52 +0000
      Re: Fixing Garbled Encodings Julian Bradfield <jcb@inf.ed.ac.uk> - 2026-02-17 15:42 +0000
        Re: Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-24 01:55 +0000
          Re: Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-24 04:41 +0000
            Re: Fixing Garbled Encodings Aidan Kehoe <kehoea@parhasard.net> - 2026-02-24 07:16 +0000
              Re: Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-24 20:24 +0000
                Re: Fixing Garbled Encodings "Henry S. Thompson" <ht@home.hst.name> - 2026-02-24 23:02 +0000
                Re: Fixing Garbled Encodings Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-02-24 23:52 +0000
                Re: Fixing Garbled Encodings "Henry S. Thompson" <ht@home.hst.name> - 2026-02-26 15:35 +0000
                Re: Fixing Garbled Encodings Aidan Kehoe <kehoea@parhasard.net> - 2026-02-26 21:24 +0000
                Re: Fixing Garbled Encodings Aidan Kehoe <kehoea@parhasard.net> - 2026-02-25 06:39 +0000
                Re: Fixing Garbled Encodings Aidan Kehoe <kehoea@parhasard.net> - 2026-02-25 13:55 +0000

csiph-web