[fpc-devel] Unicode conversion routines

Florian Klaempfl florian at freepascal.org
Sat Nov 22 09:51:29 CET 2008


Graeme Geldenhuys schrieb:
> Hi,
> 
> Has anybody written these conversions functions yet?  If not, I am
> about to port the ConvertUTF.c file from Unicode.org to Object Pascal.
> 
> 	UTF-32 to UTF-16
> 	UTF-32 to UTF-8
> 	UTF-16 to UTF-32
> 	UTF-16 to UTF-8
> 	UTF-8 to UTF-16
> 	UTF-8 to UTF-32

Please check first if the rtl routines


function UnicodeToUtf8(Dest: PChar; Source: PUnicodeChar; MaxBytes:
SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
function UnicodeToUtf8(Dest: PChar; MaxDestBytes: SizeUInt; Source:
PUnicodeChar; SourceChars: SizeUInt): SizeUInt;
function Utf8ToUnicode(Dest: PUnicodeChar; Source: PChar; MaxChars:
SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt;
Source: PChar; SourceBytes: SizeUInt): SizeUInt;
function UTF8Encode(const s : Ansistring) : UTF8String; inline;
function UTF8Encode(const s : UnicodeString) : UTF8String;
function UTF8Decode(const s : UTF8String): UnicodeString;
function AnsiToUtf8(const s : ansistring): UTF8String;{$ifdef
SYSTEMINLINE}inline;{$endif}
function Utf8ToAnsi(const s : UTF8String) : ansistring;{$ifdef
SYSTEMINLINE}inline;{$endif}
function UnicodeStringToUCS4String(const s : UnicodeString) : UCS4String;
function UCS4StringToUnicodeString(const s : UCS4String) : UnicodeString;
function WideStringToUCS4String(const s : WideString) : UCS4String;
function UCS4StringToWideString(const s : UCS4String) : WideString;

are sufficient or how they can be extended.



More information about the fpc-devel mailing list