delphidabbler / codesnip

A code bank designed with Pascal in mind
https://delphidabbler.com/software/codesnip
Other
110 stars 33 forks source link

Update code that reads user database files <= v4 to use Code Page 1252 #33

Closed delphidabbler closed 2 years ago

delphidabbler commented 2 years ago

CodeSnip's code that reads legacy user database files (v4 and earlier) treats source code data file as being encoded in the system's default ANSI code page.

This is fine in the UK, but may cause problems in other countries. Therefore the code needs to be changed to use ANSI code page 1252, which is the default code page in the UK.

Need to check other formats (e.g. the export file format) to see if they needs altering similarly.

delphidabbler commented 2 years ago

Main database file reader needs to be revised to use ANSI code page 1252 instead of Default encoding in TMainDBFileReader.GetFileEncoding.

Encodings are disposed of safely, so no worries about a memory leek using a non built in TEncoding.

delphidabbler commented 2 years ago

For user database code that needs changing to use ANSI code page 1252 is in GetSourceCodePropertyText of local function of TXMLDataReader.GetSnippetProps.

In this case encoding we need will have to be safely freed.

delphidabbler commented 2 years ago

Code importing is XML based and it seems it can be trusted.

delphidabbler commented 2 years ago

Old text backup file format use Default encoding. In this case that that is the best we can do, since files are created on user's own computer and hopefully decoded on same computer.

delphidabbler commented 2 years ago

Actually, this issue is wrong in its premise. User databases were created on their computers using their default ANSI code page, so the Default encoding is fine.

However there is a problem with old copies of the main database.

Therefore this issue is being closed and a new one relating to main database is to be opened.