From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#7786: 23.2; Encoding of PostScript files Date: Wed, 13 Oct 2021 14:49:26 +0200 Message-ID: <875yu16qeh.fsf@gnus.org> References: <877djcek3s.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13920"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 7786@debbugs.gnu.org To: Peter Dyballa Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 13 14:50:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1madi2-0003N9-Es for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 14:50:14 +0200 Original-Received: from localhost ([::1]:40718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1madi0-0001ZK-0N for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 08:50:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1madhq-0001Yx-Mr for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 08:50:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1madhq-0001u0-Db for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 08:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1madhq-0008TB-7p for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 08:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Oct 2021 12:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7786 X-GNU-PR-Package: emacs Original-Received: via spool by 7786-submit@debbugs.gnu.org id=B7786.163412937832524 (code B ref 7786); Wed, 13 Oct 2021 12:50:02 +0000 Original-Received: (at 7786) by debbugs.gnu.org; 13 Oct 2021 12:49:38 +0000 Original-Received: from localhost ([127.0.0.1]:58944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1madhS-0008SV-GL for submit@debbugs.gnu.org; Wed, 13 Oct 2021 08:49:38 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:50576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1madhQ-0008SH-C1 for 7786@debbugs.gnu.org; Wed, 13 Oct 2021 08:49:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BD4/KsUV+6PKTxiBMR/1IOKkjsSnsIdw5ty9cfyq48I=; b=t8obrtG1L4/VzIwpErpffN/kKr 5mHOf84Ts5hqH2I4Fzty/Mz9fRZ8vn92djUfg+fVblazQxVpxuw3alm4+VC0iKV3ReagJo6YH96Be Dl/dzhXojydJRO2l/TLpi3c/J1WTb5TkfX1Ds6Erdmsm0iu7jQ5mcZBeHY1g0JLgqFN4=; Original-Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1madhH-0008Hu-E9; Wed, 13 Oct 2021 14:49:29 +0200 X-Now-Playing: Sylvester's _Sylvester-Step II_: "I Been Down" In-Reply-To: <877djcek3s.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 02 Jun 2021 10:39:19 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:217116 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Lars Ingebrigtsen writes: >> IMO GNU Emacs should open a PostScript file in >> adobe-standard-encoding, except it sees in the file that the font(s) >> used is (are) re-encoded in ISOLatin1Encoding (which is *not* the same >> as ISO 8819-1), CE Encoding, or whatever. > > I took a first stab at this, but this is obviously not correct. I'm not > sure how to detect whether it's a ISOLatin1Encoding file? And... I'm > this will probably make the file opened like this be saved in utf-8, > which isn't what we want... I tested this a bit more now, and it doesn't work. First of all, saving the file with adobe-standard-encoding means that all the newlines are stripped from the file. So I tried the patch below, but 1) it didn't display non-ascii chars correctly, and 2) when saving, I got: These default coding systems were tried to encode the following problematic characters in the buffer =E2=80=98a.ps=E2=80=99: Coding System Pos Codepoint Char adobe-standard-encoding-unix 1 #xA=20=20=20=20=20=20=20=20 4 #xA=20=20=20=20=20=20=20=20 ...=20=20=20=20=20=20=20=20=20=20=20=20=20 utf-8-unix 328 #x3FFFF3=20=20=20 I.e., it's complaining about the newlines, as well as the non-ASCII char. So it seems like the adobe coding system doesn't actually work, and I wonder whether anybody's ever tried using it before? Possibly not? I've never actually tried working with the coding system stuff before on this level, so I'm probably missing something really simple. The work-in-progress patch is below, as well as a .ps test file. Anybody see immediately what's wrong here? diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf= .el index 9a68fce2e8..1fe4b5c55a 100644 --- a/lisp/international/mule-conf.el +++ b/lisp/international/mule-conf.el @@ -1637,6 +1637,7 @@ 'utf-7-imap ("\\.el\\'" . prefer-utf-8) ("\\.utf\\(-8\\)?\\'" . utf-8) ("\\.xml\\'" . xml-find-file-coding-system) + ("\\.ps\\'" . ps-find-file-coding-system) ;; We use raw-text for reading loaddefs.el so that if it ;; happens to have DOS or Mac EOLs, they are converted to ;; newlines. This is required to make the special treatment diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 5022a17db5..b2945bbbf3 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -2526,6 +2526,17 @@ sgml-html-meta-auto-coding-function (message "Warning: unknown coding system \"%s\"" match) nil))))) =20 +(defun ps-find-file-coding-system (args) + (if (not (eq (car args) 'insert-file-contents)) + 'undecided + (let ((coding-system + (coding-system-base + (detect-coding-region (point-min) (point-max) t)))) + ;; If it's an ASCII file, then interpret ` specially. + (if (memq coding-system '(undecided iso-latin-1)) + 'adobe-standard-encoding-unix + coding-system)))) + (defun xml-find-file-coding-system (args) "Determine the coding system of an XML file without a declaration. Strictly speaking, the file should be utf-8, but mistakes are --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no --=-=-= Content-Type: application/postscript Content-Disposition: attachment; filename=a.ps Content-Transfer-Encoding: base64 JSEKJSVCb3VuZGluZ0JveDogKGF0ZW5kKQolJVBhZ2VzOiAoYXRlbmQpCiUlRG9jdW1lbnRGb250 czogKGF0ZW5kKQolJUVuZENvbW1lbnRzCiUKJSBGcmFtZU1ha2VyIFBvc3RTY3JpcHQgUHJvbG9n IDIuMCwgZm9yIHVzZSB3aXRoIEZyYW1lTWFrZXIgMi4wCiUgQ29weXJpZ2h0IChjKSAxOTg2LDg3 LDg5IGJ5IEZyYW1lIFRlY2hub2xvZ3ksIEluYy4gIEFsbCByaWdodHMgcmVzZXJ2ZWQuCiUKJSBL bm93biBQcm9ibGVtczoKJQlEdWUgdG8gYnVncyBpbiBUcmFuc2NyaXB0LCB0aGUgJ1BTLUFkb2Jl LScgaXMgb21pdHRlZCBmcm9tIGxpbmUgMQoKJSBGb29gYmFyLgolIEbzbwoKCg== --=-=-=--