Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6094761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:43:03+00:00 2026-05-23T12:43:03+00:00

I have a Delphi 2006 app that I am adding code to process some

  • 0

I have a Delphi 2006 app that I am adding code to process some generated CSV data files. TStringList.LoadFromFile was giving strange results and I have just worked out the files are UTF-16 encoded.

Upgrading to XE is planned but not an option at the moment.

What’s the simplest route to handle these files with D2006? I’m assuming they can be mapped to 8-bit ASCII without any issues – they are “pure” CSV – just digits and commas, etc. and I don’t think there will be any issues with characters that are not in the 8-bit set.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:43:04+00:00Added an answer on May 23, 2026 at 12:43 pm

    TStringList does not support UTF-16 in D2006, so you will have to load and decode the file data manually before then putting the output into your TStringList. For example:

    var
      sl: TStringList;
      {$IFNDEF D2009_OR_LATER}
      ms: TMemoryStream;
      ptr: PWideChar;
      s: AnsiString;
      dlen, slen: Integer;
      {$ENDIF}
    begin
      ...
      {$IFDEF D2009_OR_LATER}
      sl.LoadFromFile('...', TEncoding.Unicode);
      {$ELSE}
      ms := TMemoryStream.Create;
      try
        ms.LoadFromFile('...');
        ptr := PWideChar(ms.Memory);
        dlen := ms.Size div SizeOf(WideChar);
        if (dlen >= 1) and (PWord(ptr)^ = $FEFF) then
        begin
          Inc(ptr);
          Dec(dlen);
        end;
        slen := WideCharToMultiByte(0, 0, ptr, dlen, nil, 0, nil, nil);
        if slen > 0 then begin
          SetLength(s, slen);
          WideCharToMultiByte(0, 0, ptr, dlen, PAnsiChar(s), slen, nil, nil));
        end;
        sl.Text := s;
      finally
        ms.Free;
      end;
      {$ENDIF}
      ...
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi 2006 app that pops up a modal alert dialog when
I have a Delphi 2006 app that writes to a file and then regularly
I am in the process of porting a Delphi 2006 app to Delphi 2009.
We have a Delphi 2006 application that drives a MS SQL Server database. We
I have an old application developed in Delphi 2006 that I now needed to
I have a fairly complex application in Delphi 2006 that communicates through an ApdComport
HI I have an application written in Delphi 2006. I have noticed that when
I have a Delphi 2006 app with a CHM help file. It all works
i have some vcl.net apps(delphi 2006 , .net 1.1 ) and i like to
HI I have a dynamic link library writting in Delphi 2006 that has forms.pas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.