[fpc-pascal] simple conversion of unicode chars

Bart bartjunk64 at gmail.com
Sun Dec 27 11:08:29 CET 2015

On 12/26/15, ulrich <romrum at cbox.cz> wrote:

> I need the simplest possible transfer of one unicode character (numeric
> string or integer) to the default windows code page (CP1250).

You mean from codepoint (U+xxxx) to single byte CP1250?

In unit LazUtf8  (in LazUtils from Lazarus):
function UnicodeToUTF8(CodePoint: cardinal): string;

In unit lconvencoding (in LazUtils from Lazarus):
function UTF8ToCP1250(const s: string; SetTargetCodePage: boolean =
false): RawByteString; // central europe

The LazUtils package can be used in console programs as well (it does
not depend on LCL or widgetset).
In lazarus, start a new project (simple program) then use the
projectIspectro to add a dependency on LazUtils package (this will add
the right paths to the project info file).

That should do the trick.


More information about the fpc-pascal mailing list