How do I specify a codepage to use when loading a document into TAdvMemo?
Similar to the standard TMemo, you can specify the encoding with
Thanks. This seems more limited though if it can only accept encodings like UTF8, ASCII, Unicode, and BigEndianUnicode. Someone please correct me if I'm wrong. :)
As explained, the codepage should be set via AdvMemo.Font.Charset.
NOTE: I really wish this forum let you edit your posts but I don't see that option. I often like to go back and clarify things or make corrections in my posts and replies but it seems I can't do that in this forum.
- This doesn't affect loading file. There is no such capability to store along with a plain text file a code page. Setting the font.CharSet should be sufficient.2. Sorry, editing is preserved for admins.
- I don't understand how you cannot aplply the codepage found to AdvMemo.Font.CharSet.2. The forum software is a module we bought and I'm not sure it is configurable in such way. We'd need to investigate.
Oh, I do realize that you already pointed out that some encodings can be specified when loading, but not nearly as many as would be able to with a codepage parameter.
Then please explain what you think you can NOT do?
For example, how would I load a file encoded with codepage 28598 (iso-8859-8)? And then save it back out using the same codepage?
As I explained already, there is no convention for storing codepage in a plaintext file. You'd need to determine this somehow from the content. As such there is also not a convention for storing it.
All that can be done is heuristically determine it from an existing file and adapt the Font.Charset for it. The only other encodings are for non-ANSI text files, like UTF8, UTF16 encoding etc.. and this can be handled with the Encoding parameter of LoadFromFile()
So the final answer is that TAdvMemo cannot load a document using a given codepage (except for the few that can be specified with System::Sysutils::TEncoding) even though LMD SyntaxEdit allows this... and apparently there is no interest in adding support for this.
Nothing prevents you from extracting this codepage from the file type you wish to use with TAdvMemo and apply the code page you retrieve to Font.CharSet. TAdvMemo primary focus is programming languages (Pascal, Basic, C#, JS that have no codepage at all)