AEncoding

From Free Pascal wiki
Revision as of 14:51, 29 May 2019 by Alextp (talk | contribs)
Jump to navigationJump to search

About

This is small unit which partly replaces LazUtils.LConvEncoding. It gives few functions to convert strings from/to some encoding:

function AEncodingConvertFromUTF8(const AInput: RawByteString; out AOutput: RawByteString;
  AEnc: TSystemCodePage): boolean; inline;

function AEncodingConvertToUTF8(const AInput: RawByteString; out AOutput: RawByteString;
  AEnc: TSystemCodePage): boolean; inline;

function AEncodingConvertFromTo(const AInput: RawByteString; out AOutput: RawByteString;
  AEncInput, AEncOutput: TSystemCodePage): boolean;

To use functions with "string" var, do this:

 AEncoding....(RawByteString(S), ....);

Why "partly replaces"? Because it uses FPC 3.x SetCodePage, which requires OS support for many encodings. While LConvEncoding doesn't require OS support. For common encodings (CP1250...CP1258, CP437, CP866 etc) OS support should work, on Windows and Unix'es.

It also gives few integer constants aeid_NNNN for common encodings.

  • Author: Alexey Torgashin.
  • License: MPL 2.0 or LGPL.

Download

GitHub: https://github.com/Alexey-T/AEncoding