fpspreadsheet: Use UTF8 with BOM as default encoding for CSV reader/writer (better compatibility with Excel/LOCalc, see https://forum.lazarus.freepascal.org/index.php/topic,40527.msg280025.html#msg280025)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6257 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
d87367be7a
commit
15a617af53
@ -97,6 +97,9 @@ uses
|
|||||||
DateUtils, LConvEncoding, Math,
|
DateUtils, LConvEncoding, Math,
|
||||||
fpsUtils, fpsNumFormat;
|
fpsUtils, fpsNumFormat;
|
||||||
|
|
||||||
|
const
|
||||||
|
DEFAULT_ENCODING = 'utf8bom';
|
||||||
|
|
||||||
function LineEndingAsString(ALineEnding: TsCSVLineEnding): String;
|
function LineEndingAsString(ALineEnding: TsCSVLineEnding): String;
|
||||||
begin
|
begin
|
||||||
case ALineEnding of
|
case ALineEnding of
|
||||||
@ -198,6 +201,8 @@ begin
|
|||||||
encoding := GuessEncoding(s)
|
encoding := GuessEncoding(s)
|
||||||
else
|
else
|
||||||
encoding := CSVParams.Encoding;
|
encoding := CSVParams.Encoding;
|
||||||
|
if encoding = '' then
|
||||||
|
encoding := DEFAULT_ENCODING;
|
||||||
|
|
||||||
// Create worksheet
|
// Create worksheet
|
||||||
FWorksheet := FWorkbook.AddWorksheet(FWorksheetName, true);
|
FWorksheet := FWorkbook.AddWorksheet(FWorksheetName, true);
|
||||||
@ -256,7 +261,7 @@ begin
|
|||||||
FFormatSettings := CSVParams.FormatSettings;
|
FFormatSettings := CSVParams.FormatSettings;
|
||||||
ReplaceFormatSettings(FFormatSettings, FWorkbook.FormatSettings);
|
ReplaceFormatSettings(FFormatSettings, FWorkbook.FormatSettings);
|
||||||
if CSVParams.Encoding = '' then
|
if CSVParams.Encoding = '' then
|
||||||
FEncoding := 'utf8'
|
FEncoding := DEFAULT_ENCODING
|
||||||
else
|
else
|
||||||
FEncoding := CSVParams.Encoding;
|
FEncoding := CSVParams.Encoding;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user