Recent

Author Topic: Windows API and wide/unicode strings  (Read 4455 times)

cdbc

  • Hero Member
  • *****
  • Posts: 1752
    • http://www.cdbc.dk
Re: Windows API and wide/unicode strings
« Reply #15 on: November 30, 2023, 09:45:15 am »
Hi
I often use shortstrings across library borders for convenience and pchar for longer strings. I have a couple of routines for easy switching between string & pchar, it's sort of a mix  :D A while ago I posted a "StringStack" in one of @Joanna's threads, that class has all the string/pchar functions in it, see if you can find it  ;)
This nifty mix makes my life easier, at least  ::)
Regards Benny 
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Thaddy

  • Hero Member
  • *****
  • Posts: 16319
  • Censorship about opinions does not belong here.
Re: Windows API and wide/unicode strings
« Reply #16 on: November 30, 2023, 10:55:07 am »
A stringstack for any string type is available through any of the generics modes and is basically a one liner.....
There is nothing wrong with being blunt. At a minimum it is also honest.

cdbc

  • Hero Member
  • *****
  • Posts: 1752
    • http://www.cdbc.dk
Re: Windows API and wide/unicode strings
« Reply #17 on: November 30, 2023, 11:35:11 am »
Hi
Well, I guess Joanna had special needs, then...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Thaddy

  • Hero Member
  • *****
  • Posts: 16319
  • Censorship about opinions does not belong here.
Re: Windows API and wide/unicode strings
« Reply #18 on: November 30, 2023, 12:26:30 pm »
Yes.
Code: Pascal  [Select][+][-]
  1. program stringstest;
  2. {$mode delphi}
  3. uses generics.collections;
  4. type
  5.  TShortStringStack = TStack<ShortString>;// one line
  6.  TUnicodeStringStack = TStack<UnicodeString>;// one line
  7.  TAnsiStringStack = TStack<AnsiString>;// one line
  8. // etc.
  9. begin
  10. end.
So I really wonder what somebody was smoking... O:-)
« Last Edit: November 30, 2023, 01:27:59 pm by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

cdbc

  • Hero Member
  • *****
  • Posts: 1752
    • http://www.cdbc.dk
Re: Windows API and wide/unicode strings
« Reply #19 on: November 30, 2023, 03:10:48 pm »
Hi
@Thaddy: ...But Mom, I Swear.. it's oregano.  %)
...and the code was just using some strnew/strdispose, etc stuff 8-)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Nadar

  • New Member
  • *
  • Posts: 17
Re: Windows API and wide/unicode strings
« Reply #20 on: November 30, 2023, 08:08:58 pm »
I'm kind of "clinging" to the statement found on the mailing list here: https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg42244.html
Quote
Quote
Best for me would be to be able to turn the conversions off completely.

You cannot, but you can set DefaultSystemCodePage to CP_UTF8.
Then no conversions will be done for all ansistrings that contain UTF8.

IF this is actually true, there should be a way.

Oregano aside, this is the question I really need an answer to. I can try to test if it's true, but it's very hard to make sure that I cover "all options". What would be very much easier is if somebody could confirm that it's indeed the case.

 

TinyPortal © 2005-2018