Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: UNICODESTRING vs ANSISTRING

  1. #11
    Sorry for the double post, but I have to say this: the solution was trivial

    While testing I discovered that function StrPas (used internally to force some callings to overloaded functions in my abstraction layer unit) were in a different unit in modern Delphi (AnsisString instead of SysUtils), so I added it to be used only in Delphi. Since then warnings appeared again and I was like WTF Delphi is trolling me... But using the Find declaration command to see the actual declaration of Format I discovered AnsiString also defines it's own version using ANSISTRING instead of UNICODESTRING!

    Note it doesn't avoid the need of the abstraction layer unit, but it simplifies a lot the implementation of this unit (and avoids to call an extra function internally in other units). For example:
    Code:
      USES
      {$IFDEF ISDELPHI2009ANDUP}
      { This unit implements sysutils using ANSISTRING instead of UNICODESTRING,
        which is the default in modern Delphi compilers. }
        AnsiStrings;
      {$ELSE}
        sysutils;
      {$ENDIF}
    
    ··· 
    
      FUNCTION al_str_format (CONST Fmt: AL_STR; CONST Args : ARRAY OF CONST)
        : AL_STR;
      BEGIN
        Format (Fmt, Args)
      END;
    This way there's no need of conditional compilation outside Allegro.pas.

    So, now we know.
    Last edited by Ñuño Martínez; 21-02-2020 at 11:58 AM.
    No signature provided yet.

  2. #12
    Wait Delphi has a special unit just for dealing with ANSI strings? I must shamefully admit that I didn't knew that

  3. #13
    Well, you know now.

    Anyway I think they should add an option to tell the compiler to define STRING as ANSISTRING, as FPC does with {$unicodestrings} or something. That would help a lot porting and maintaining code.
    No signature provided yet.

  4. #14
    Mother of Strings!!! it's highly inefficient and error prone to have multiple, obscure and undocumented units to deal with the same task.

  5. #15
    If you mean the AnsiStrings unit, I agree. If I were Delphi developer I would overload the functions adding UNICODESTRING, without breaking backwards compatibility.

    If you mean my al5strings... well, I didn't found a better solution.
    No signature provided yet.

  6. #16
    I meant AnsiStrings unit. That's a mistake. Your al5strings unit is a fix on a mistake made by others.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •