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

peter green plugwash at p10link.net
Wed Nov 28 03:46:04 CET 2007


Felipe Monteiro de Carvalho wrote:
> 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?
>
> thanks,
>   

The whole point of the widestring manager system that it allows you to 
replace the default conversion routines with whatever conversion you 
wish. If you want UTF-8 then just write a set of widestring manager 
routines that do UTF-8. If you want ones that use the windows conversion 
APIs (which let you convert to any code page that is installed in the 
system by specifying it's codepage number) write ones that use the 
windows coversion APIs. If you want ones that use ICU write ones that 
use ICU and so on.







More information about the fpc-devel mailing list