Jump to content


Mountain

Member Since 28 Dec 2010
Offline Last Active Mar 08 2026 02:31 PM
-----

Posts I've Made

In Topic: LoadFromCSV not working

08 March 2026 - 02:31 PM

In the unit NxStdCtrls6 I added the if HighByte = 0.... else part seen below. After that I can load a csv-file that is saved with Encoding = ekUnicode.
{ Read the second byte }
if Encoding <> ekAnsi then
begin
  BytesRead := FileRead(FileHandle, HighByte, SizeOf(Byte));
       
  if HighByte = 0 then
    wc := WideChar(LowByte)
  else
    wc := GetValue(HighByte, LowByte);
  end
Perhaps a more correct way is if (Encoding = ekUnicode) and (HighByte = 0), or to alter the function GetValue in some way?

In Topic: LoadFromCSV not working

17 December 2025 - 12:10 PM

Hi,

 

I understand. It is not easy.

So SaveToFile will be altered to save files as UTF8, instead of UTF16? Sounds good, preferably non BOM.

I'm looking forward to the update. smile.png


In Topic: LoadFromCSV not working

07 December 2025 - 02:01 PM

I noticed that the CSV file is saved as UTF16 with BOM.

If I resave the CSV file as ANSI or UTF8 without BOM, then the import works.

 

So, if you don't need unicode then you can add NxTypes6 to the unit, under uses, and set

grGroup.Serialize.Encoding := ekAnsi; //replace grGroup with the name of your TNxGrid6 component

 

And, in that case, any previously saved CSV needs to be converted to ANSI.

 

 

Seems like a problem with the support for UTF16 in LoadFromFile?


In Topic: LoadFromCSV not working

12 June 2025 - 11:49 PM

I came here to report the error "List index out of bounds (-1). TInterfaceList is empty." when using LoadFromCSV, and noticed there is already a topic for it. Maybe it only occurs in Delphi 12?

 

I'm attaching a demo project.

There is a "Test.csv" that I've created using the demo, but I can't load it back.

 

Demo features:

Press Insert to add rows to the grid.

Click Save to save grid content as "Test.csv" in exe-folder.

Click Open to load "Test.csv" from exe-folder.