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 957937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:47:10+00:00 2026-05-16T00:47:10+00:00

We are upgrading our project from Delphi 2006 to Delphi 2010. Old code was:

  • 0

We are upgrading our project from Delphi 2006 to Delphi 2010. Old code was:

InputText: string;
InputText := SomeTEditComponent.Text;
...
for i := 1 to length(InputText) do
if InputText[i] in ['0'..'9', 'a'..'z', 'Ř' { and more special characters } ] then ...

Trouble is with accent letters – compare will fail.

I tried switch source code from ANSI to UTF8 and LE UCS-2 but without luck. Only cast as AnsiChar works:

if CharInSet(AnsiChar(InputText[i]), ['0'..'9', 'a'..'z', 'Ř']) then

Funny is how Delphi works with that letters – try this in Evaluate during debugging:

Ord('Ř') = Ord('Ø')

(yes, Delphi says True, on Windows 7 Czech)


Question is: How can I store and compare simple strings without forcing them as AnsiStrings? Because if this is not working why we should use Unicode?

Thanks all for reply

Right now we are using in some parts simple CharInSet(AnsiChar(…

  • 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-16T00:47:11+00:00Added an answer on May 16, 2026 at 12:47 am

    As mentioned by Uwe Raabe, the problem with Unicode char is, they’re pretty large. If Delphi allowed you to create an “set of Char” it would be 8 Kb in size! An “set of AnsiChar” is only 32 bytes in size, pretty manageable.

    I’d like to offer some alternatives. First is a sort of drop-in replacement for the CharInSet function, one that uses an array of CHAR to do the tests. It’s only merit is that it can be called immediately from almost anywhere, but it’s benefits stop there. I’d avoid this if I can:

    function UnicodeCharInSet(UniChr:Char; CharArray:array of Char):Boolean;
    var i:Integer;
    begin
      for i:=0 to High(CharArray) do
        if CharArray[i] = UniChr then
        begin
          Result := True;
          Exit;
        end;
      Result := False;
    end;
    

    The trouble with this function is that it doesn’t handle the x in ['a'..'z'] syntax and it’s slow! The alternatives are faster, but aren’t as close to a drop-in replacement as one might want. The first set of alternatives to be investigated are the string functions from Microsoft. Amongst them there’s IsCharAlpha and IsCharAlphanumeric, they might fix lots of issues. The problem with those, all “alpha” chars are the same: You might end up with valid Alpha chars in non-enlgish non-czech languages. Alternatively you can use the TCharacter class from Embarcadero – the implementation is all in the Character.pas unit, and it looks effective, I have no idea how effective Microsoft’s implementation is.

    An other alternative is to write your own functions, using an “case” statement to get things to work. Here’s an example:

    function UnicodeCharIs(UniChr:Char):Boolean;
    var i:Integer;
    begin
      case UniChr of
        'ă': Result := True;
        'ş': Result := False;
        'Ă': Result := True;
        'Ş': Result := False;
        else Result := False;
      end;
    end;
    

    I inspected the assembler generated for this function. While Delphi has to implement a series of “if” conditions for this, it does it very effectively, way better then implementing the series of IF statements from code. But it could use a lot of improvement.

    For tests that are used ALOT you might want to look for some bit-mask based implementation.

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

Sidebar

Related Questions

We're upgrading a project from Sitefinity 3.7 to 4.4 and some of our controls
We are upgrading our application from Delphi 2007 to Delphi XE2, which includes unicode
We are just upgrading our ASP.Net shop implementation (from simple one) to structure that
We are upgrading our XL C/C++ compiler from V8.0 to V10.1 and found some
My team is moving to TFS 2010, but all of our old projects are
Currently I'm working on a project at work and we're looking at upgrading our
I work on a large project in an organization that is (slowly) upgrading our
We are in the process of upgrading our projects from C# 2.0 / VS2005
We are upgrading our application from JBoss 4 to JBoss 6. A couple of
We've been successful in upgrading our SSRS servers from 2005 to 2008. Now when

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.