Difference between revisions of "AEncoding"

From Lazarus wiki
Jump to navigationJump to search
(New page)
 
(→‎Download: why Category:Data types ?)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
=About=
 
=About=
This is small unit which partly replaces LazUtils.LConvEncoding. It gives few functions to convert strings from/to some encoding:
+
'''AEncoding''' is a small unit, which partly replaces LazUtils.LConvEncoding. It provides a few functions for converting strings from/to some encoding schemes:
  
<syntaxhighlight>
+
<syntaxhighlight lang="pascal">
 
function AEncodingConvertFromUTF8(const AInput: RawByteString; out AOutput: RawByteString;
 
function AEncodingConvertFromUTF8(const AInput: RawByteString; out AOutput: RawByteString;
 
   AEnc: TSystemCodePage): boolean; inline;
 
   AEnc: TSystemCodePage): boolean; inline;
Line 16: Line 16:
 
   AEncoding....(RawByteString(S), ....);
 
   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, etc) OS support should work on Windows and Unix'es.
+
Why "partly replaces"?
 +
 
 +
* It uses FPC 3.x SetCodePage, which requires OS support for many encodings, whereas LConvEncoding doesn't require OS support. For common encodings (CP1250...CP1258, CP437, CP866 etc) OS support should work, on Windows and Unix'es.
 +
* FPC SetCodePage doesn't raise exceptions, while LConvEncoding can do it (when global variable is set in LConvEncoding unit).
 +
 
 +
It also gives few integer constants aeid_NNNN for common encodings.
 +
 
 +
* Author: Alexey Torgashin.
 +
* License: MPL 2.0 or LGPL.
  
 
=Download=
 
=Download=
 
GitHub: https://github.com/Alexey-T/AEncoding
 
GitHub: https://github.com/Alexey-T/AEncoding
 +
 +
[[Category:Unicode]]

Latest revision as of 13:17, 22 December 2023

About

AEncoding is a small unit, which partly replaces LazUtils.LConvEncoding. It provides a few functions for converting strings from/to some encoding schemes:

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"?

  • It uses FPC 3.x SetCodePage, which requires OS support for many encodings, whereas LConvEncoding doesn't require OS support. For common encodings (CP1250...CP1258, CP437, CP866 etc) OS support should work, on Windows and Unix'es.
  • FPC SetCodePage doesn't raise exceptions, while LConvEncoding can do it (when global variable is set in LConvEncoding unit).

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