I a file in ASCII-format, coming from the PC/DOS-world, and an application that makes use of it (reads some informations from it). The application is developed for several platforms, among them the Mac, but it’s coming from even the pre-Windows eon - therefore the ASCII-thing.
OK. Now I have another file in ASCII-format, coming from the DOS-world as well, and for some reason I would like to add its content to the firstmentioned file.
Now - how to do this on a Mac???
I have TextWrangler, but until today I couldn’t figure out how to handle ASCII-files with it. I get lost in all these formats (Unix-Lineendings, UTF-whatever and so on), and anyway, Textwrangler opens a file the way it wants to open it; I am not asked. And when it opens an ASCII-file, I see all umlauts and stuff changed to strange characters that, unfortunately, stay this way when I save.
you sure that is an ascii file? typically ascii was limited to the non-multi byte format…
Anyway, try vi. It is an old command line editor, but if you can open a file, and see the characters right, then we can point you in the right direction. To open a file named goober.txt located in ~/foo/bar open terminal, cd to ~/foo/bar then type
Now you are in the vi editor. typing :q will quit the editor. You can find a list of vi commands with a quick search in google.
Since you already have TextWrangler, you could also try opening the document then going to the menu “Edit > Document Options …”, and change the settings to see how that changes the way the document displays.
This option changes the encoding in which Textwrangler saves the file, not the way the file is opened or displayed. Textwrangler has a menu entry named “File->Reopen Using Encoding” for that too, but the support for legacy encodings is probably too limited anyway. I think Jaysen is right to go with vim (or macvim, which might be bit more user-friendly and less intimidating than the command-line version ).
:e ++enc=850 % reopen the file in CP850 enoding
:set encoding=UTF-8 % change encoding to UTF-8 Unicode
:w % save the file
No problem, the vim editor can do that, but you have identify the two encodings used by your DOS programs first. I would try IBM/CP 437, 850, 852 and 858, as those were popular encodings for german texts during the DOS era.
What is it that keeps obfuscated, unusable editors alive over decades…? I hoped this one was gone the way of the dinosaurs meanwhile. It did already confuse me thirty years ago, when I was not too comforted by other software.
Contrary to what I said above, you may also be able to edit your files in TextWrangler. There are some optional encodings available, that can be enabled in TextWrangler’s Preferences menu:
You can reopen a file in an encoding of your choice by selecting “Reopen Using Encoding” in TextWrangler’s File menu. To save the file in a different encoding, click on the button in Textwrangler’s status bar and change the line breaks from Unix to DOS/Windows (CR+LF), if necessary: