[fpc-pascal] Delphi / FPC and UTF8 BOM

Marco van de Voort marcov at stack.nl
Wed Oct 22 14:12:23 CEST 2008


In our previous episode, Martin Schreiber said:
> > No, since then the runtime routines must be overloaded again, for each
> > compiler magic'ed type (all codepages +UTF-8, and another two).
> >
> > A runtime routine must be able to detect what kind of string type it
> > receives, or you need a runtime routine per type.
> 
> Or the compiler adds the conversion to the function call because at 
> compiletime the encoding of both types are known. Delphi converts always to 
> an intermediate utf-16 AFAIK.

No, not always. It often does so for actual processing, but not when it
passes to a procedure that simply passes the string on to the next.

And that is the problem in your case. You can't declare a procedure to
accept a general ansistring, just to pass it on, since then the type info is
lost. Having a general ansistring limits the conversion when passed to
procedures that only accept a certain encoding, and to the (typically leaf-)
procedures that do actual processing.

Moreover, the 4 bytes encoding are not a real problem. If it can save a
conversion here and there, it is already better.



More information about the fpc-pascal mailing list