|
Previous Top Next |
.
Windows-1251, KOI8-R, ISO-8859-5 DOS.
– , ,
, 160 - "", 150 – "" . .
( ).
.
, , .
.
Code: |
procedure TForm1.Button1Click(Sender: TObject); var code1, code2: TCode; s: string; c: char; i: integer; chars: array [char] of char; str: array [TCode] of string; begin case ComboBox1.ItemIndex of 1: code1 := koi; 2: code1 := iso; 3: code1 := dos; else code1 := win; end; case ComboBox2.ItemIndex of 1: code2 := koi; 2: code2 := iso; 3: code2 := dos; else code2 := win; end; s := Memo1.Text;
Str[win] := ''; Str[koi] := ''; Str[iso] := ''; Str[dos] := ' "''""';
for c := #0 to #255 do Chars[c] := c;
for i := 1 to Length(Str[win]) do Chars[Str[code2][i]] := Str[code1][i];
for i := 1 to Length(s) do s[i] := Chars[s[i]];
Memo2.Text := s; end; |
©Drkb::01958
Code: |
unit ConvertEncodingUnit; interface type // TCodeMatrix = array[1..255] of char; {****************************************************************************** {ANSI, KOI8-R, KOI8-U, OEM/DOS, ISO 6 ( TCodeMatrix): 1. cmAnsiToKoi8R - ANSI KOI8-R 2. cmAnsiToKoi8U - ANSI KOI8-U 3. cmKoi8RToAnsi - KOI8-R ANSI 4. cmKoi8UToAnsi - KOI8-U ANSI 5. cmOemDosToAnsi - OEM/DOS ANSI 6. cmIsoToAnsi - ISO ANSI ******************************************************************************} function ConvertEncoding(sIn: string; sCoding: string): string;
const // FirstCodes = #1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28+ #29#30#31' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^' + '_`abcdefghijklmnopqrstuvwxyz{|}~'; cmAnsiToKoi8R: TCodeMatrix = FirstCodes // ver 1.0, VEG, 31.10.2003 + ' ' + ''; cmAnsiToKoi8U: TCodeMatrix = FirstCodes // ver 0.8, VEG, 31.10.2003 + ' ' + ''; cmKoi8RToAnsi: TCodeMatrix = FirstCodes // ver 1.0, VEG, 31.10.2003 + '--L-++T++------?v??? ???=-㬬LLL---TTT+++' + ''; cmKoi8UToAnsi: TCodeMatrix = FirstCodes // ver 1.0, VEG, 31.10.2003 + '--L-++T++------?v??? ???=-㳿LLL-T+' + ''; cmOemDosToAnsi: TCodeMatrix = FirstCodes // ver 1.0, VEG, 31.10.2003 + '---+---L+T+-+L' + 'T=+TTLL-++-----v '; cmIsoToAnsi: TCodeMatrix = FirstCodes // ver 1.0, VEG, 31.10.2003 + '??????????????????????????????? ' + '';
implementation
function ConvertEncoding(sIn: string; sCoding: string): string; //sIn - //sCoding - //result - var iFtd: integer; begin Result:=''; for iFtd := 1 to length(sIn) do result := result + sCoding[ord(sIn[iFtd])]; end; // ver 1.0, (C)Vrublevsky Evgeny Gennadyevich (BELARUS/SLUTSK), 31.10.2003 {******************************************************************************} end. |
RoboSol
©Drkb::01959
() Win 8- EMail?
Code: |
const Koi: Array[0..66] of Char = ("T", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); Win: Array[0..66] of Char = ("", "", "T", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
function WinToKoi(Str: String): String; var i, j, Index: Integer; begin Result := ""
for i := 1 to Length(Str) do begin Index := -1; for j := Low(Win) to High(Win) do if Win[j] = Str[i] then begin Index := j; Break; end;
if Index = -1 then Result := Result + Str[i] else Result := Result + Koi[Index]; end; end;
function KoiToWin(Str: String): String; var i, j, Index: Integer; begin Result := ""
for i := 1 to Length(Str) do begin Index := -1; for j := Low(Win) to High(Win) do if Koi[j] = Str[i] then begin Index := j; Break; end;
if Index = -1 then Result := Result + Str[i] else Result := Result + Win[Index]; end; end;
procedure SendFileOnSMTP(Host: String; Port: Integer; Subject, FromAddress, ToAddress, Body, FileName: String); var NMSMTP: TNMSMTP; begin if DelSpace(ToAddress) = "" then Exit; if ToAddress[1] = "" then Exit;
if (DelSpace(FileName) <> "") and not FileExists(FileName) then raise Exception.Create("SendFileOnSMTP: file not exist: " + FileName);
NMSMTP := TNMSMTP.Create(nil); try NMSMTP.Host := Host; NMSMTP.Port := Port; NMSMTP.Charset := "koi8-r" NMSMTP.PostMessage.FromAddress := FromAddress; NMSMTP.PostMessage.ToAddress.Text := ToAddress; NMSMTP.PostMessage.Attachments.Text := FileName; NMSMTP.PostMessage.Subject := Subject; NMSMTP.PostMessage.Date := DateTimeToStr(Now); NMSMTP.UserID := "netmaster" NMSMTP.PostMessage.Body.Text := WinToKoi(Body); NMSMTP.FinalHeader.Clear; NMSMTP.TimeOut := 5000; NMSMTP.Connect; NMSMTP.SendMail; NMSMTP.Disconnect; finally NMSMTP.Free; end; end; |
©Drkb::01960
. Windows-1251, KOI8-R, ISO-8859-5 DOS. , , , 160 - "", 150 "" . . ( ). . , , .
.
Code: |
procedure TForm1.Button1Click(Sender: TObject); var code1, code2: TCode; s: string; c: char; i: integer; chars: array [char] of char; str: array [TCode] of string; begin case ComboBox1.ItemIndex of 1: code1 := koi; 2: code1 := iso; 3: code1 := dos; else code1 := win; end; case ComboBox2.ItemIndex of 1: code2 := koi; 2: code2 := iso; 3: code2 := dos; else code2 := win; end; s := Memo1.Text;
Str[win] := ''; Str[koi] := ''; Str[iso] := '?????????s?z??Y'; Str[dos] := ' ????????S?"??Z???''?s??zY';
for c := #0 to #255 do Chars[c] := c;
for i := 1 to Length(Str[win]) do Chars[Str[code2][i]] := Str[code1][i];
for i := 1 to Length(s) do s[i] := Chars[s[i]];
Memo2.Text := s; end;
|
©Drkb::01961
DelphiWorld 6.0
Перекодировка текста DOS-Windows-Koi8
Code: |
procedure WinToDos; var Src, Str: PChar; begin Src := Memo1.Lines.GetText; // TMemo PChar CharToOem(Src, Str); //API Memo2.Lines.Text := StrPas(Str);// end;
procedure DosToWin; var Src, Str: PChar; begin Src := Memo1.Lines.GetText; // TMemo PChar OemToChar(Src, Str); //API Memo2.Lines.Text := StrPas(Str);// end;
var koi8toalt : array [0..127] of char = ( CHR($c4), Chr($b3), Chr($da), Chr($bf), Chr($c0), Chr($d9), Chr($c3), Chr($b4), Chr($c2), Chr($c1), Chr($c5), Chr($df), Chr($dc), Chr($db), Chr($dd), Chr($de), Chr($b0), Chr($b1), Chr($b2), Chr($f4), Chr($fe), Chr($f9), Chr($fb), Chr($f7), Chr($f3), Chr($f2), Chr($ff), Chr($f5), Chr($f8), Chr($fd), Chr($fa), Chr($f6), Chr($cd), Chr($ba), Chr($d5), Chr($f1), Chr($d6), Chr($c9), Chr($b8), Chr($b7), Chr($bb), Chr($d4), Chr($d3), Chr($c8), Chr($be), Chr($bd), Chr($bc), Chr($c6), Chr($c7), Chr($cc), Chr($b5), Chr($f0), Chr($b6), Chr($b9), Chr($d1), Chr($d2), Chr($cb), Chr($cf), Chr($d0), Chr($ca), Chr($d8), Chr($d7), Chr($ce), Chr($fc), Chr($ee), Chr($a0), Chr($a1), Chr($e6), Chr($a4), Chr($a5), Chr($e4), Chr($a3), Chr($e5), Chr($a8), Chr($a9), Chr($aa), Chr($ab), Chr($ac), Chr($ad), Chr($ae), Chr($af), Chr($ef), Chr($e0), Chr($e1), Chr($e2), Chr($e3), Chr($a6), Chr($a2), Chr($ec), Chr($eb), Chr($a7), Chr($e8), Chr($ed), Chr($e9), Chr($e7), Chr($ea), Chr($9e), Chr($80), Chr($81), Chr($96), Chr($84), Chr($85), Chr($94), Chr($83), Chr($95), Chr($88), Chr($89), Chr($8a), Chr($8b), Chr($8c), Chr($8d), Chr($8e), Chr($8f), Chr($9f), Chr($90), Chr($91), Chr($92), Chr($93), Chr($86), Chr($82), Chr($9c), Chr($9b), Chr($87), Chr($98), Chr($9d), Chr($99), Chr($97), Chr($9a));
function Koi8toWin(const Data: PChar; DataLen: Integer): PChar; var PCh: PChar; i: Integer; begin PCh := Data; for i := 1 to DataLen do begin if Ord(Pch^) > 127 then Pch^ := koi8toalt[Ord(Pch^) - 128]; Inc(PCh); end; PCh := Data; OemToCharBuff(PCh, PCh, DWORD(DataLen)); Result := Data; end; |
©Drkb::01962
DelphiWorld 6.0
Перекодировка текста из Win1251 в KOI8-R и наоборот
Code: |
type TConvertChars = array [#128..#255] of char;
const Win_KoiChars: TConvertChars = ( #128,#129,#130,#131,#132,#133,#134,#135,#136,#137,#060,#139,#140,#141,#142,#143, #144,#145,#146,#147,#148,#169,#150,#151,#152,#153,#154,#062,#176,#157,#183,#159, #160,#246,#247,#074,#164,#231,#166,#167,#179,#169,#180,#060,#172,#173,#174,#183, #156,#177,#073,#105,#199,#181,#182,#158,#163,#191,#164,#062,#106,#189,#190,#167, #225,#226,#247,#231,#228,#229,#246,#250,#233,#234,#235,#236,#237,#238,#239,#240, #242,#243,#244,#245,#230,#232,#227,#254,#251,#253,#154,#249,#248,#252,#224,#241, #193,#194,#215,#199,#196,#197,#214,#218,#201,#202,#203,#204,#205,#206,#207,#208, #210,#211,#212,#213,#198,#200,#195,#222,#219,#221,#223,#217,#216,#220,#192,#209);
Koi_WinChars: TConvertChars = ( #128,#129,#130,#131,#132,#133,#134,#135,#136,#137,#138,#139,#140,#141,#142,#143, #144,#145,#146,#147,#148,#149,#150,#151,#152,#153,#218,#155,#176,#157,#183,#159, #160,#161,#162,#184,#186,#165,#166,#191,#168,#169,#170,#171,#172,#173,#174,#175, #156,#177,#178,#168,#170,#181,#182,#175,#184,#185,#186,#187,#188,#189,#190,#185, #254,#224,#225,#246,#228,#229,#244,#227,#245,#232,#233,#234,#235,#236,#237,#238, #239,#255,#240,#241,#242,#243,#230,#226,#252,#251,#231,#248,#253,#249,#247,#250, #222,#192,#193,#214,#196,#197,#212,#195,#213,#200,#201,#202,#203,#204,#205,#206, #207,#223,#208,#209,#210,#211,#198,#194,#220,#219,#199,#216,#221,#217,#215,#218);
function Win_KoiConvert(const St: string): string; var i: integer; begin Result:=St; for i:=1 to Length(St) do if St[i]>#127 then Result[i]:=Win_KoiChars[St[i]]; end; |
©Drkb::01963
DelphiWorld 6.0