[fpc-devel] Controlling the output of the widestring manager

Daniël Mantione daniel.mantione at freepascal.org
Tue Nov 27 20:37:32 CET 2007



Op Tue, 27 Nov 2007, schreef Felipe Monteiro de Carvalho:

> Hello,
> 
> Today I took a look at what would be necessary to implement
> controlling the output of the widestring manager, and implementing
> this looks rather trivial.
> 
> The only thing we need is a switch, to control if widestrings should
> be converted to the current locale or to utf-8. In the case of current
> locale one can use the current widestring function Wide2AnsiMoveProc .
> In case of utf-8 we can use the cross-platform UnicodeToUTF8 function.
> 
> I would start by adding a new field to TWideStringManager:
> 
> OutputUTF8ToStrings: Boolean;
> 
> Then when converting a widestring to a short string one should check
> which procedure to call.
> 
> I could check all places that call Wide2AnsiMoveProc and instead do:
> 
> if OutputUTF8ToStrings then UnicodeToUTF8()
> else Wide2AnsiMoveProc ()
> 
> Or we could add a procedure which does this automatically. Or maybe
> something else.
> 
> So, which would be the prefered way?

A more generic solution is necessary; one can want to output strings in a 
specific encoding, utf-8 is only one of the specific encodings that are 
demanded. Therefore a boolean is not a good solution.

Daniël


More information about the fpc-devel mailing list