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

  • SEARCH
  • Home
  • 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 1066313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:59:45+00:00 2026-05-16T19:59:45+00:00

In Delphi 2009 and later versions, string type implicitly equal to UnicodeString type. My

  • 0

In Delphi 2009 and later versions, string type implicitly equal to UnicodeString type. My discipline now is to use explicit UnicodeString type for my recent base units to eliminate the confusion. Is there a compiler directive that will make string <> UnicodeString in the unit where it was stated?

  • 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-16T19:59:46+00:00Added an answer on May 16, 2026 at 7:59 pm

    If you want to have a codebase that can be compiled under Unicode and non-Unicode Delphi’s you should be aware of the usage of each occurance of string – is it a string being passed to a Windows API? Do you want to call the ‘Delphi native’ version, or do you want to call the Ansi version or Wide version explicitly? Is it a string being exchanged with RTL/VCL code? Is it a string from a database? Does it need to support Unicode, Ansi or any other encoding? Etc.

    In my experience, code interacting with Delphi RTL/VCL and WinAPI’s (as declared in Windows.pas and such) are best being served with string itself, as it transparently means AnsiString or UnicodeString, depending on the compiler being used. If the specific purpose of the string makes the distinction Ansi or Unicode important, use AnsiSting or UnicodeString explicitly. This introduces a problem with older Delphi’s as they don’t have a UnicodeString. In practice this can largly be solved by defining a UncodeString yourself in some central unit like this:

    {$IF NOT DECLARED(UnicodeString)}
    type UnicodeString = WideString;
    {$IFEND}
    

    If on the other hand you want your code to be configurable to use Ansi or Unicode, use your own string type as often as possible. Define it something like this :

    {$IFDEF MY_APP_USE_UNICODE}
    type AppString = UnicodeString;
    {$ELSE}
    type AppString = AnsiString;
    {$ENDIF}
    

    .. and work with that in your own code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Delphi 2009 has changed its string type to use 2 bytes to represent a
Delphi 2009 introduced a hierarchical system for project options configuration, where you set base
In Delphi 2009 I'm finding that any time I use TThread.CurrentThread in an application,
In Delphi 2009 or later (Unicode), are there any built-in functions or small routines
Delphi 2009, among some cool stuff, has also just got Anonymous methods. I've seen
In Delphi 2009 whereabouts do you turn on the option to treat warnings as
On Delphi 2009, on a new VCL project: procedure TForm1.FormCreate(Sender: TObject); var Handle: THandle;
I installed both the Delphi 2009 trial and actual release via the web installer
I just got Delphi 2009 and have previously read some articles about modifications that
One of Delphi 2009's advertised features was PNG support. That's great, because the Unicode

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.