Стартовый пул

This commit is contained in:
2024-04-02 08:46:59 +03:00
parent fd57fffd3a
commit 3bb34d000b
5591 changed files with 3291734 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
unit synex_charset;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, lconvencoding;
type
TTextCharset = (
tcUnknown, tcUTF8, tcUTF8BOM, tcISO_8859_1, tcISO_8859_2, tcCP1250, tcCP1251, tcCP1252, tcCP1253,
tcCP1254, tcCP1255, tcCP1256, tcCP1257, tcCP1258, tcCP437, tcCP850, tcCP852, tcCP866, tcCP874,
tcKOI8, tcUCS2LE, tcUCS2BE, tcCP936, tcCP950, tcCP949, tcCP932
);
{stdcalls}
function GetTextCharset (const AText: String): TTextCharset; STDCALL;
function ConvertToUtf8 (const AText: String; const AEncoding: TTextCharset): String; STDCALL;
function ConvertFromUtf8 (const AText: String; const AEncoding: TTextCharset): String; STDCALL;
implementation
function GetTextCharset (const AText: String): TTextCharset;
var cur_charst: String;
begin
Result:= tcUnknown;
cur_charst:= lowerCase(GuessEncoding(AText));
if cur_charst = 'utf8' then
Result:= tcUTF8;
if cur_charst = 'utf8bom' then
Result:= tcUTF8BOM;
if cur_charst = 'iso_8859_1' then
Result:= tcISO_8859_1;
if cur_charst = 'iso_8859_2' then
Result:= tcISO_8859_2;
if cur_charst = 'cp1250' then
Result:= tcCP1250;
if cur_charst = 'cp1251' then
Result:= tcCP1251;
if cur_charst = 'cp1252' then
Result:= tcCP1252;
if cur_charst = 'cp1253' then
Result:= tcCP1253;
if cur_charst = 'cp1254' then
Result:= tcCP1254;
if cur_charst = 'cp1255' then
Result:= tcCP1255;
if cur_charst = 'cp1256' then
Result:= tcCP1256;
if cur_charst = 'cp1257' then
Result:= tcCP1257;
if cur_charst = 'cp1258' then
Result:= tcCP1258;
if cur_charst = 'cp437' then
Result:= tcCP437;
if cur_charst = 'cp850' then
Result:= tcCP850;
if cur_charst = 'cp852' then
Result:= tcCP852;
if cur_charst = 'cp866' then
Result:= tcCP866;
if cur_charst = 'cp874' then
Result:= tcCP874;
if cur_charst = 'koi8' then
Result:= tcKOI8;
if cur_charst = 'ucs2le' then
Result:= tcUCS2LE;
if cur_charst = 'ucs2be' then
Result:= tcUCS2BE;
if cur_charst = 'cp936' then
Result:= tcCP936;
if cur_charst = 'cp950' then
Result:= tcCP950;
if cur_charst = 'cp949' then
Result:= tcCP949;
if cur_charst = 'cp932' then
Result:= tcCP932;
end;
function ConvertToUtf8 (const AText: String; const AEncoding: TTextCharset): String;
begin
case AEncoding of
tcUTF8BOM: Result:= UTF8BOMToUTF8(AText);
tcISO_8859_1: Result:= ISO_8859_1ToUTF8(AText);
tcISO_8859_2: Result:= ISO_8859_2ToUTF8(AText);
tcCP1250: Result:= CP1250ToUTF8(AText);
tcCP1251: Result:= CP1251ToUTF8(AText);
tcCP1252: Result:= CP1252ToUTF8(AText);
tcCP1253: Result:= CP1253ToUTF8(AText);
tcCP1254: Result:= CP1254ToUTF8(AText);
tcCP1255: Result:= CP1255ToUTF8(AText);
tcCP1256: Result:= CP1256ToUTF8(AText);
tcCP1257: Result:= CP1257ToUTF8(AText);
tcCP1258: Result:= CP1258ToUTF8(AText);
tcCP437: Result:= CP437ToUTF8(AText);
tcCP850: Result:= CP850ToUTF8(AText);
tcCP852: Result:= CP852ToUTF8(AText);
tcCP866: Result:= CP866ToUTF8(AText);
tcCP874: Result:= CP874ToUTF8(AText);
tcKOI8: Result:= KOI8ToUTF8(AText);
tcUCS2LE: Result:= UCS2LEToUTF8(AText);
tcUCS2BE: Result:= UCS2BEToUTF8(AText);
tcCP936: Result:= CP936ToUTF8(AText);
tcCP950: Result:= CP950ToUTF8(AText);
tcCP949: Result:= CP949ToUTF8(AText);
tcCP932: Result:= CP932ToUTF8(AText);
else
Result:= AText;
end;
end;
function ConvertFromUtf8 (const AText: String; const AEncoding: TTextCharset): String;
begin
case AEncoding of
tcUTF8BOM: Result:= UTF8ToUTF8BOM(AText);
tcISO_8859_1: Result:= UTF8ToISO_8859_1(AText);
tcISO_8859_2: Result:= UTF8ToISO_8859_2(AText);
tcCP1250: Result:= UTF8ToCP1250(AText);
tcCP1251: Result:= UTF8ToCP1251(AText);
tcCP1252: Result:= UTF8ToCP1252(AText);
tcCP1253: Result:= UTF8ToCP1253(AText);
tcCP1254: Result:= UTF8ToCP1254(AText);
tcCP1255: Result:= UTF8ToCP1255(AText);
tcCP1256: Result:= UTF8ToCP1256(AText);
tcCP1257: Result:= UTF8ToCP1257(AText);
tcCP1258: Result:= UTF8ToCP1258(AText);
tcCP437: Result:= UTF8ToCP437(AText);
tcCP850: Result:= UTF8ToCP850(AText);
tcCP852: Result:= UTF8ToCP852(AText);
tcCP866: Result:= UTF8ToCP866(AText);
tcCP874: Result:= UTF8ToCP874(AText);
tcKOI8: Result:= UTF8ToKOI8(AText);
tcUCS2LE: Result:= UTF8ToUCS2LE(AText);
tcUCS2BE: Result:= UTF8ToUCS2BE(AText);
tcCP936: Result:= UTF8ToCP936(AText);
tcCP950: Result:= UTF8ToCP950(AText);
tcCP949: Result:= UTF8ToCP949(AText);
tcCP932: Result:= UTF8ToCP932(AText);
else
Result:= AText;
end;
end;
end.

View File

@@ -0,0 +1,12 @@
unit synex_register;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, synex_syncharmngr;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents ('SynEdit', [TSynEditCharsetManager]);
end;
end.

View File

@@ -0,0 +1,68 @@
unit synex_syncharmngr;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, synex_charset, SynEdit;
type
TSynEditCharsetManager = class (TComponent)
private
FCharset: TTextCharset;
FSynEdit: TSynEdit;
public
constructor Create (AOwner: TComponent);
destructor Destroy;
procedure LoadFromStream (Stream: TStream);
procedure LoadFromFile (const FileName: String);
procedure SaveToStream(Stream: TStream);
procedure SaveToFile(const FileName: String);
published
property Charset: TTextCharset read FCharset;
property SynEdit: TSynEdit read FSynEdit write FSynEdit;
end;
implementation
{TCharsetStrings}
constructor TSynEditCharsetManager.Create (AOwner: TComponent);
begin
inherited Create(AOwner);
FCharset:= tcUTF8;
FSynEdit:= Nil;
end;
destructor TSynEditCharsetManager.Destroy;
begin
FSynEdit:= Nil;
inherited Destroy;
end;
procedure TSynEditCharsetManager.LoadFromStream (Stream: TStream);
var SL: TStringList;
begin
SL:= TStringList.Create;
SL.LoadFromStream(Stream);
FCharset:= GetTextCharset(SL.Text);
SL.Text:= ConvertToUtf8(SL.Text, FCharset);
FSynEdit.Lines.Assign(SL);
FreeAndNil(SL);
end;
procedure TSynEditCharsetManager.LoadFromFile (const FileName: String);
var FS: TFileStream;
begin
FS:= TFileStream.Create(FileName, fmOpenRead + fmShareDenyNone);
LoadFromStream(FS);
FreeAndNil(FS);
end;
procedure TSynEditCharsetManager.SaveToStream(Stream: TStream);
var SL: TStringList;
begin
SL:= TStringList.Create;
SL.Assign(FSynEdit.Lines);
SL.Text:= ConvertFromUtf8(SL.Text, FCharset);
SL.SaveToStream(Stream);
FreeAndNil(SL);
end;
procedure TSynEditCharsetManager.SaveToFile(const FileName: String);
var FS: TFileStream;
begin
FS:= TFileStream.Create(FileName, fmOpenWrite + fmShareDenyWrite);
SaveToStream(FS);
FreeAndNil(FS);
end;
end.

51
SynEditEx/syneditex.lpk Normal file
View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="syneditex"/>
<Type Value="RunAndDesignTime"/>
<Author Value="Alexander Babaev"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Description Value="Empowering SynEdit"/>
<License Value="Same as SynEdit package"/>
<Version Minor="1"/>
<Files Count="3">
<Item1>
<Filename Value="data\synex_charset.pas"/>
<UnitName Value="synex_charset"/>
</Item1>
<Item2>
<Filename Value="data\synex_syncharmngr.pas"/>
<UnitName Value="synex_syncharmngr"/>
</Item2>
<Item3>
<Filename Value="data\synex_register.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="synex_register"/>
</Item3>
</Files>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="SynEdit"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
</Package>
</CONFIG>

22
SynEditEx/syneditex.pas Normal file
View File

@@ -0,0 +1,22 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit syneditex;
{$warn 5023 off : no warning about unused units}
interface
uses
synex_charset, synex_syncharmngr, synex_register, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('synex_register', @synex_register.Register);
end;
initialization
RegisterPackage('syneditex', @Register);
end.