[fpc-pascal] PWideChar vs. ^

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Mar 13 19:42:31 CET 2009


On 13 Mar 2009, at 19:05, Marc Santhoff wrote:

> Am Freitag, den 13.03.2009, 18:14 +0100 schrieb Jonas Maebe:
>>
>> Please always include a compilable sample program when asking
>> questions about code behaviour. Without it, all that can be done is
>> hand waving.
>
> I was more interested in some general guidelines about using (pointers
> to) widestrings and conversion to ansistring eventually.

There are none, at least not regarding "don't do this or your program  
will crash with an access violation" (well, typecasting a pwidestring  
to a pwidechar can cause crashes since they are unrelated types, but  
as far as I understood you did not get a crash in that case -- you  
won't get correct results either in the long run, though).

Of course, assigning a widestring to an ansistring always risks data  
loss due to the fact that the ansistring may not be able to represent  
all characters in the widestring, but that's it.

> The details are
> visible from the code, but bringing the different parts of my data
> classes and a lcl-treeview in harmony with wide strings handed in  
> (from
> fpc-xml, but that could be anything else) costs me much time  
> currently.

Without a sample that demonstrates the problem you are seeing, I  
cannot help.

> Reading the installed documentation (pdf) of fpc 2.2.2 doesn't enlight
> me so far, no mention of unit "cwstring" at all. Only some conversion
> routines I cannot relate to what I'm doing.

It's all internal compiler magic, which is not documented anywhere.


Jonas



More information about the fpc-pascal mailing list