[fpc-devel] Unicode and UTF8String

Marco van de Voort marcov at stack.nl
Mon Dec 1 14:08:25 CET 2008

In our previous episode, Martin Friebe said:
> >>
> >> ?
> >>     
> >
> > Why would you do this and not
> > MyString := SomeRTLRoutine;
> > ?
> >   
> If I understand that right, this may cause some overhead, that in 
> some(few) cases is not needed.

> If I write an application using  stringtype "X" (WideString for 
> example), then in the above "MyString" would be WideString.


> The in/ouput for SomeRTLRoutine are RtlString, they are OS depended. If 
> I compile for a OS using "UTF8" then that means for each and every call, 
> it needs a string conversation.


> Of course I understand, *if* some RTLFunction calls the OS, then the 
> string must be converted. But if I simply want to extract the drive 
> letter, or trim the path, and get the file name, without actually 
> accessing the file or OS? Should it be possible to skip converting?

Use rtlstring. Do the conversion to widestring after.

IOW, you should do it the other way around. Use the OS dependant stringtype
for mostly encoding independant operations, and only the few things where
you need specific encodings force a certain encoding (using utf8string or


More information about the fpc-devel mailing list