Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-03

fpc_ShortStr_To_WideStr

9 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

C Western

Is the assignment to Size meant to be commented out? (I have just started having trouble with a program which I think has just started using widestrings because the DOM unit has been switched to widestrings.) Colin

Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString;
{$ifdef hascompilerproc} compilerproc; {$endif}
{
  Converts a ShortString to a WideString;
}
Var
  Size : SizeInt;
begin
  //Size:=Length(S2);

Reply by email

peter green
to C Western

oops looks like i commented out the wrong line when changing the widestringmanager system for improved flexibility.

the code should be:

Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString;
{$ifdef hascompilerproc} compilerproc; {$endif}
{
  Converts a ShortString to a WideString;
}
Var
  Size : SizeInt;
begin
  Size:=Length(S2);
  //Setlength (fpc_ShortStr_To_WideStr,Size);
  if Size>0 then
    begin

widestringmanager.Ansi2WideMoveProc(PChar(@S2[1]),fpc_ShortStr_To_WideStr,Si ze);
{ Terminating Zero }

PWideChar(Pointer(fpc_ShortStr_To_WideStr)+Size*sizeof(WideChar))^:=#0;
    end;
end;
Show quoted text 26 lines
-----Original Message----- From: Behalf Of C Western Sent: 21 March 2005 21:37 To: FPC developers' list Subject: [fpc-devel] fpc_ShortStr_To_WideStr Is the assignment to Size meant to be commented out? (I have just started having trouble with a program which I think has just started using widestrings because the DOM unit has been switched to widestrings.) Colin Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString; {$ifdef hascompilerproc} compilerproc; {$endif} { Converts a ShortString to a WideString; } Var Size : SizeInt; begin //Size:=Length(S2); _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Van Canneyt
to C Western: Is the assignment to Size meant to be commented out? (I have just started having trouble…
C Western wrote
Is the assignment to Size meant to be commented out? (I have just started having trouble with a program which I think has just started using widestrings because the DOM unit has been switched to widestrings.)

The DOM unit has always been using widestrings.
As for the comment: it should _not_ be commented out, obviously, since the size is used in statements further on.
Florian or Peter should be able to comment on this, I think.

Michael.

Reply by email

C Western
to peter green: oops looks like i commented out the wrong line when changing the widestringmanager system…
peter green wrote 27 lines
oops looks like i commented out the wrong line when changing the widestringmanager system for improved flexibility. the code should be: Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString; {$ifdef hascompilerproc} compilerproc; {$endif} { Converts a ShortString to a WideString; } Var Size : SizeInt; begin Size:=Length(S2); //Setlength (fpc_ShortStr_To_WideStr,Size); if Size>0 then begin widestringmanager.Ansi2WideMoveProc(PChar(@S2[1]),fpc_ShortStr_To_WideStr,Si ze); { Terminating Zero } PWideChar(Pointer(fpc_ShortStr_To_WideStr)+Size*sizeof(WideChar))^:=#0; end; end;

Thanks for the quick response. That fix works for me. Colin

Reply by email

Alexey Barkovoy
to peter green: oops looks like i commented out the wrong line when changing the widestringmanager system…

While we on theme. At least in FPC 1.9.8 there is bug in compiler: it can't internally convert "constant AnsiChar" to "constant WideChar".

=====================================
uses SysUtils;
const sConst =  'W';
procedure Do1(const w: PWideChar);
begin StrToInt(w); end;
begin
  Do1(sConst); //Error: Incompatible type for arg no. 1: Got "Char", expected
"PWideChar"
  Do1('W');    //Error: Incompatible type for arg no. 1: Got "Char", expected
"PWideChar"
  Do1('WW');   // SUCCEEDED
end.

=====================================

Reply by email

Peter Vreman
to Alexey Barkovoy
While we on theme. At least in FPC 1.9.8 there is bug in compiler: it can't internally convert "constant AnsiChar" to "constant WideChar".

Use the bug database to report bugs. Bugs reported on the mailing list will be forgotten.

Reply by email

Peter Vreman
to Alexey Barkovoy
Show quoted text 7 lines
> Use the bug database to report bugs. Bugs reported on the mailing list > will be forgotten. I know, but www.freepascal.org & cvs.freepascal.org are down (?) altrow pings show they are active...

The bug database worked for me 1 hour ago.

Reply by email