I have a lot of text files. They all have a .TXT suffix.
Most of the time I want to treat them as UTF-8.
However, there are some sets of files that are intended to be ANSI.
Opening these as UTF-8 will mangle a few characters.
Is there any way to configure Textpad to treat specific directories as ANSI and others as UTF-8?
Default to ANSI sometimes
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
I don't believe there is a way to specify the encoding by directory. But you can specify the encoding by filename extension:
in
Configure | Preferences | Document Classes | <Class>
for
Default encoding:
select ANSI or UTF-8.
You can override this when opening an individual file by specifying the Encoding.
in
Configure | Preferences | Document Classes | <Class>
for
Default encoding:
select ANSI or UTF-8.
You can override this when opening an individual file by specifying the Encoding.
C:\Users\---\AppData\Roaming\Helios\TextPad\8\ConfigState.xml
contains entries for document classes in this format ...
So, the test currently seems to be restricted to the filename.suffix and ignores the path.
This matches what we see in Preferences / Document Classes
I will log an enhancement request to widen the tests.
contains entries for document classes in this format ...
Code: Select all
<class name="Text" type="2">
<value name="Members" type="collection">
<element>*.</element>
<element>*.TXT</element>
<element>*.INI</element>
...
This matches what we see in Preferences / Document Classes
I will log an enhancement request to widen the tests.
If you want all the text files in a subfolder to be opened as ANSI, when the default is UTF-8, you can use .editorconfig files, as suggested by MudGuard.
Create a file named .editorconfig in the particular subfolder with the following contents:
Enable handling of such files on Configure/Preferences/Editor settings.
Note that TextPad will then recursively search for .editorconfig files in every parent folder, accumulating overrides as it goes. This can slow things down with remote files, so it's best to create one starting with "root = true" in the topmost folder you want to override settings for.
Note also that if after doing this you open the file from the recently used list on the File menu, it will still open with the character encoding it was last opened with.
The settings which can be overridden are documented here:
https://editorconfig-specification.readthedocs.io/
I hope this helps.
Create a file named .editorconfig in the particular subfolder with the following contents:
Code: Select all
[*.txt]
charset = latin1
Note that TextPad will then recursively search for .editorconfig files in every parent folder, accumulating overrides as it goes. This can slow things down with remote files, so it's best to create one starting with "root = true" in the topmost folder you want to override settings for.
Note also that if after doing this you open the file from the recently used list on the File menu, it will still open with the character encoding it was last opened with.
The settings which can be overridden are documented here:
https://editorconfig-specification.readthedocs.io/
I hope this helps.