From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.devel Subject: Re: converting octal escape sequences to utf-8 and back Date: Sun, 29 May 2011 01:40:54 -0400 Message-ID: <87vcwuysgp.fsf@maru.md5i.com> References: <19937.37639.583480.682350@gargle.gargle.HOWL> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1306647673 3626 80.91.229.12 (29 May 2011 05:41:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 29 May 2011 05:41:13 +0000 (UTC) Cc: Roland Winkler To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 29 07:41:06 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QQYkK-0004zk-W3 for ged-emacs-devel@m.gmane.org; Sun, 29 May 2011 07:41:05 +0200 Original-Received: from localhost ([::1]:39472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQYkK-0001Ih-5K for ged-emacs-devel@m.gmane.org; Sun, 29 May 2011 01:41:04 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQYkI-0001Ic-Bt for emacs-devel@gnu.org; Sun, 29 May 2011 01:41:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QQYkH-0000cR-8U for emacs-devel@gnu.org; Sun, 29 May 2011 01:41:02 -0400 Original-Received: from md5i.com ([75.151.244.229]:33142 helo=maru.md5i.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQYkH-0000ba-5h; Sun, 29 May 2011 01:41:01 -0400 Original-Received: from md5i by maru.md5i.com with local (Exim 4.76) (envelope-from ) id 1QQYkA-0004qB-Se; Sun, 29 May 2011 01:40:54 -0400 In-Reply-To: (Leo's message of "Sun, 29 May 2011 10:57:20 +0800") User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 75.151.244.229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:139868 Archived-At: Leo writes: > On 2011-05-29 08:27 +0800, Roland Winkler wrote: >> I am trying to use emacs to interface with a program that treats >> utf-8 characters in its input and output as octal escape sequences. >> So the program's output contains ascii strings like "\302\247", >> which I want to display within Emacs as "=A7". Likewise, I want to >> feed text containing utf-8 characters such as "=A7" into this program. >> So I need to convert these utf-8 characters back to their respective >> octal escape sequences. What is the proper way to achieve this? >> >> Thanks a lot, >> >> Roland > > Are these functions useful? > > encode-coding-string, decode-coding-string > encode-coding-region, decode-coding-region As Leo says: (encode-coding-string "=A7" 'utf-8) "\302\247" (decode-coding-string "\302\247" 'utf-8) "=A7" --=20 Michael Welsh Duggan (md5i@md5i.com)