Skip to content

Unicode

Pr. James Hunter edited this page Aug 7, 2021 · 1 revision

Unicode in the LPatternMatch.Core unit

LPatternMath engine is Unicode-aware and it can freely work with UTF-16 encoded strings (which are default Unicode string on FPC and Delphi compilers; C++ makes UTF-16 usage through the wchar_t* data type as I know).

Turning it on and off

Unicode mode is turned on by definition of {$Define Unicode} in the engine file (LPatternMatch.Core.pas). It is turned on by default.

If you do not need Unicode data to be processed - you might want to turn it off by commenting out the directive like this, for example {.$Define Unicode}.

Using static ranges

But even with commented Unicode switch engine unit will use Character unit, which works with Unicode characters and introduces additional size overheads for your application. Therefore, if you would work only with English characters (means only with first 127 ASCII characters), then you can turn on {$Define UseStaticRanges} switch in the same file, which tells engine to use static assertion based on compiled-in ranges of characters. Using static ranges may significantly decrease size of executable and increase the speed of execution, as it will throw away Character unit dependency.