View Issue Details

IDProjectCategoryView StatusLast Update
0035444FPCDocumentationpublic2019-04-30 10:18
ReporterMarco van de VoortAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0035444: Document widestring internal
DescriptionReal widestring (so on Windows) apparently has the length in the structure in bytes, rather than chars. Setlength and length() do work on words though. Even though it is an internal detail, it might be worthwhile to document or at least hint on this, since it is a Windows internal type, and one of the key reasons of widestring<>unicodestring (the other being using COM compatible allocation, that also could be mentioned in the docs)

Delphi's docs do too.

See also related report.
Steps To Reproducevar s : widestring;
setlength(s,5)';
writeln(pdword(@s[1])[-1]);

will write 10.
TagsNo tags attached.
Fixed in Revision1602.
FPCOldBugId
FPCTarget3.2.0
Attached Files

Relationships

related to 0035359 closedSven Barth Wrong dwarf-3 info for unicodestring 

Activities

Serge Anvarov

2019-04-25 20:05

reporter   ~0115809

In "Steps To Reproduce" WideString, not string.
Additional information: the length field for WideString is always Int32 (no matter 32 or 64 bit), unlike the Ansi/Unicode string where it is SizeInt. It is compatible with Windows.
Additional information: the length field for Ansi/Unicode string is not compatible with Delphi, where it is always Int32. I think that the implementation of Delphi will later be upgraded to FPC level.

Marco van de Voort

2019-04-25 20:56

manager   ~0115811

Changed string -> widestring in steps. Thanks

Sven Barth

2019-04-26 00:29

manager   ~0115817

Also WideString unlike Ansi-/UnicodeString is not reference counted, thus there is more copying involved when passing them around.

Michael Van Canneyt

2019-04-30 10:18

administrator   ~0115913

Noted that the memory layout differs from Unicodestring and that in particular the length is stored in bytes.

Issue History

Date Modified Username Field Change
2019-04-25 18:22 Marco van de Voort New Issue
2019-04-25 18:22 Marco van de Voort Status new => assigned
2019-04-25 18:22 Marco van de Voort Assigned To => Michael Van Canneyt
2019-04-25 18:22 Marco van de Voort Relationship added related to 0035359
2019-04-25 18:22 Marco van de Voort Description Updated View Revisions
2019-04-25 18:23 Marco van de Voort Description Updated View Revisions
2019-04-25 18:57 Marco van de Voort Description Updated View Revisions
2019-04-25 20:05 Serge Anvarov Note Added: 0115809
2019-04-25 20:55 Marco van de Voort Steps to Reproduce Updated View Revisions
2019-04-25 20:56 Marco van de Voort Note Added: 0115811
2019-04-26 00:29 Sven Barth Note Added: 0115817
2019-04-30 10:18 Michael Van Canneyt Status assigned => resolved
2019-04-30 10:18 Michael Van Canneyt Resolution open => fixed
2019-04-30 10:18 Michael Van Canneyt Fixed in Version => 3.3.1
2019-04-30 10:18 Michael Van Canneyt Fixed in Revision => 1602.
2019-04-30 10:18 Michael Van Canneyt FPCTarget => 3.2.0
2019-04-30 10:18 Michael Van Canneyt Note Added: 0115913