help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple encodings in one file


From: Lambert, Joshua D
Subject: Re: Multiple encodings in one file
Date: Mon, 29 Apr 2024 18:45:52 +0000

Thank you for the time. What you said gives me some hope but I have a follow-up 
question. If I visit a file literally, make a change, and save it, the file 
seems to be different only where I changed it. Is that true?

If so, then does the following seem reasonable.

  1.
Find a file literally.
  2.
The user will accept that some characters will show octal codes or something 
similar.
  3.
Edit the records where understandable and possible.
  4.
Save file.

Furthermore, if I want to try to convert the MARC8 encoded records to UTF8 
(mappings are available), is it reasonable/possible for me to do that in the 
buffer after using find-file-literally or would it be better to do that using 
hexl-mode, or another method?

Thanks,
Joshua

________________________________
From: help-gnu-emacs-bounces+jlambert=missouristate.edu@gnu.org 
<help-gnu-emacs-bounces+jlambert=missouristate.edu@gnu.org> on behalf of Eli 
Zaretskii <eliz@gnu.org>
Sent: Monday, April 29, 2024 2:22 AM
To: help-gnu-emacs@gnu.org <help-gnu-emacs@gnu.org>
Subject: Re: Multiple encodings in one file

CAUTION: External Sender


> From: "Lambert, Joshua D" <JLambert@MissouriState.edu>
> Date: Mon, 29 Apr 2024 04:20:54 +0000
> msip_labels:
>
> Question: If I open a file that uses one encoding in one part of the file and 
> another encoding in another part of the file, and also uses multiple 
> character sets, can I edit a small part of it in Emacs, using UCS (Unicode), 
> without Emacs changing the rest of the file?

No.  The built-in machinery for encoding and decoding file's contents
when visiting or saving files assumes the same encoding for the entire
file.  To support files whose different parts are encoded differently,
you will need to decode each part "by hand": visit the file literally,
then loop over each part and decode each part using
decode-coding-region.  When saving, do the opposite.

This message originated outside Missouri State University. Please use caution 
when opening attachments, clicking links, or replying.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]