Page 1 of 1
Default to ANSI sometimes
Posted: Thu Aug 04, 2022 7:40 am
by IanOfYork
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?
Posted: Thu Aug 04, 2022 9:17 am
by ben_josephs
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.
Posted: Thu Aug 04, 2022 2:04 pm
by IanOfYork
I have a lot of text files. They all have a .TXT suffix.
So far, Textpad only seems aware of the file suffix.
It would be good (for me) if there was an option for a regex against the full
path/filename.suffix, but I suspect that nobody else would find this to be of any use.
Posted: Thu Aug 04, 2022 3:20 pm
by MudGuard
I have no experience with this, but as much as I have read, .editorconfig could be a solution (but don't ask me what exactly has to be put into that file ...)
Posted: Thu Aug 04, 2022 3:45 pm
by IanOfYork
C:\Users\---\AppData\Roaming\Helios\TextPad\8\ConfigState.xml
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>
...
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.
Suggested
Posted: Sun Aug 07, 2022 10:40 am
by IanOfYork
Posted: Sun Oct 09, 2022 8:27 am
by bbadmin
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.
Posted: Sat Dec 03, 2022 7:55 am
by ineuw
I dealt with such issues by creating a different document class with its own extension. But then, I don't share files just store them in the cloud.