Conversion to and from UTF32(BE)
Closed this issue · 1 comments
adem0x commented
I am mostly interested in conversion to and from UTF32(BE).
How can I do these conversions?
UTF32 --> UTF8
UTF32 --> UTF16
UTF32 --> UTF16BE
UTF32BE --> UTF8
UTF32BE --> UTF16
UTF32BE --> UTF16BE
and
UTF8 --> UTF32
UTF16 --> UTF32
UTF16BE --> UTF32
UTF8 --> UTF32BE
UTF16 --> UTF32BE
UTF16BE --> UTF32BE
Thank you.
d-mozulyov commented
var
LContext: TUniConvContext;
LDestinationWritten: NativeUInt;
LSourceRead: NativeUInt;
begin
LContext.Init(CODEPAGE_UTF8 {To}, CODEPAGE_UTF32{BE} {From});
LContext.Convert(ADestination, ADestinationSize,
ASource, ASourceSize,
LDestinationWritten, LSourceRead); // output values
Several initialization methods:
// "constructors"
procedure Init(const ADestinationCodePage, ASourceCodePage: Word; const ACharCase: TCharCase = ccOriginal); overload;
procedure Init(const ADestinationBOM, ASourceBOM: TBOM; const SBCSCodePage: Word = 0; const ACharCase: TCharCase = ccOriginal); overload;
// most frequently used "constructors"
procedure InitSBCSFromSBCS(const ADestinationCodePage, ASourceCodePage: Word; const ACharCase: TCharCase = ccOriginal);
procedure InitUTF8FromSBCS(const ASourceCodePage: Word; const ACharCase: TCharCase = ccOriginal);
procedure InitSBCSFromUTF8(const ADestinationCodePage: Word; const ACharCase: TCharCase = ccOriginal);
procedure InitUTF16FromSBCS(const ASourceCodePage: Word; const ACharCase: TCharCase = ccOriginal);
procedure InitSBCSFromUTF16(const ADestinationCodePage: Word; const ACharCase: TCharCase = ccOriginal);
procedure InitUTF8FromUTF8(const ACharCase: TCharCase);
procedure InitUTF16FromUTF16(const ACharCase: TCharCase);
procedure InitUTF8FromUTF16(const ACharCase: TCharCase);
procedure InitUTF16FromUTF8(const ACharCase: TCharCase);
See demos\FileConversion.dpr and documentation also.