建议收录

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
回复人: zswang(伴水)(被黑中) (2001-12-12 22:46:10) 得0分 //建议收录
function StringGridToString(mStringGrid: TStringGrid): string;
var
I, J: Integer;
T: string;
begin
Result := '';
for J := 0 to mStringGrid.RowCount - 1 do begin
T := '';
for I := 0 to mStringGrid.ColCount - 1 do
T := T + #9 + mStringGrid.Cells[I, J];
Delete(T, 1, 1);
Result := Result + T + #13#10;
end;
end; { StringGridToString }
procedure StringToStringGrid(mStr: string; mStringGrid: TStringGrid);
var
I, J: Integer;
T: string;
begin
with TStringList.Create do try
Text := mStr;
for I := 0 to mStringGrid.ColCount - 1 do begin
T := '';
for J := 0 to Min(mStringGrid.RowCount - 1, Count - 1) do
mStringGrid.Cells[I, J] := ListValue(Strings[J], I, #9);
end;
finally
Free;
end;
end; { StringToStringGrid }
uses
Math;
function QuotedPrintableEncode(mSource: string): string;
var
I, J: Integer;
begin
Result := '';
J := 0;
for I := 1 to Length(mSource) do begin
if mSource in [#32..#127, #13, #10] - ['='] then begin
Result := Result + mSource;
Inc(J);
end else begin
Result := Result + '=' + IntToHex(Ord(mSource), 2);
Inc(J, 3);
end;
if mSource in [#13, #10] then J := 0;
if J >= 70 then begin
Result := Result + #13#10;
J := 0;
end;
end;
end; { QuotedPrintableEncode }
function QuotedPrintableDecode(mCode: string): string;
var
I, J, L: Integer;
begin
Result := '';
J := 0;
L := Length(mCode);
I := 1;
while I <= L do begin
if mCode = '=' then begin
Result := Result + Chr(StrToIntDef('$' + Copy(mCode, I + 1, 2), 0));
Inc(J, 3);
Inc(I, 3);
end else if mCode in [#13, #10] then begin
if J < 72 then Result := Result + mCode;
if mCode = #10 then J := 0;
Inc(I);
end else begin
Result := Result + mCode;
Inc(J);
Inc(I);
end;
end;
end; { QuotedPrintableDecode }
const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function IntToDigit(mNumber: Integer; mScale: Byte; mLength: Integer = 0): string;
var
I, J: Integer;
begin
Result := '';
I := mNumber;
while (I >= mScale) and (mScale > 1) do begin
J := I mod mScale;
I := I div mScale;
Result := cScaleChar[J + 1] + Result;
end;
Result := cScaleChar[I + 1] + Result;
if mLength > 0 then
for I := 1 to mLength - Length(Result) do
Result := '0' + Result;
end; { IntToDigit }
function DigitToInt(mDigit: string; mScale: Byte): Integer;
var
I: Byte;
L: Integer;
begin
Result := 0;
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
Trunc(IntPower(mScale, I - 1));
end; { DigitToInt }
const
cBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
function Base64Encode(mSource: string; mAddLine: Boolean = True): string;
var
I, J: Integer;
S: string;
T: string;
begin
Result := '';
J := 0;
for I := 0 to Length(mSource) div 3 - 1 do begin
S := Copy(mSource, I * 3 + 1, 3);
T := IntToDigit(Ord(S[1]), 2, 8) + IntToDigit(Ord(S[2]), 2, 8) + IntToDigit(Ord(S[3]), 2, 8);
Result := Result + cBase64[DigitToInt(Copy(T, 01, 6), 2) + 1];
Result := Result + cBase64[DigitToInt(Copy(T, 07, 6), 2) + 1];
Result := Result + cBase64[DigitToInt(Copy(T, 13, 6), 2) + 1];
Result := Result + cBase64[DigitToInt(Copy(T, 19, 6), 2) + 1];
if mAddLine then begin
Inc(J, 4);
if J >= 76 then begin
Result := Result + #13#10;
J := 0;
end;
end;
end;
I := Length(mSource) div 3;
S := Copy(mSource, I * 3 + 1, 3);
case Length(S) of
1: begin
T := IntToDigit(Ord(S[1]), 2, 8) + '0000';
Result := Result + cBase64[DigitToInt(Copy(T, 01, 6), 2) + 1];
Result := Result + cBase64[DigitToInt(Copy(T, 07, 6), 2) + 1];
Result := Result + '=';
Result := Result + '=';
end;
2: begin
T := IntToDigit(Ord(S[1]), 2, 8) + IntToDigit(Ord(S[2]), 2, 8) + '0000';
Result := Result + cBase64[DigitToInt(Copy(T, 01, 6), 2) + 1];
Result := Result + cBase64[DigitToInt(Copy(T, 07, 6), 2) + 1];
Result := Result + cBase64[DigitToInt(Copy(T, 13, 6), 2) + 1];
Result := Result + '=';
end;
end;
end;
function StringToSysCharSet(mStr: string): TSysCharSet;
var
I: Integer;
begin
Result := [];
for I := 1 to Length(mStr) do
Include(Result, mStr);
end; { StringToSysCharSet }
function Base64Decode(mCode: string): string;
var
I, L: Integer;
S: string;
T: string;
begin
Result := '';
L := Length(mCode);
I := 1;
while I <= L do begin
if Pos(mCode, cBase64) > 0 then begin
S := Copy(mCode, I, 4);
if (Length(S) = 4) then begin
T := IntToDigit(Pos(S[1], cBase64) - 1, 2, 6) +
IntToDigit(Pos(S[2], cBase64) - 1, 2, 6) +
IntToDigit(Pos(S[3], cBase64) - 1, 2, 6) +
IntToDigit(Pos(S[4], cBase64) - 1, 2, 6);
Result := Result + Chr(DigitToInt(Copy(T, 01, 8), 2));
if S[3] <> '=' then begin
Result := Result + Chr(DigitToInt(Copy(T, 09, 8), 2));
if S[4] <> '=' then
Result := Result + Chr(DigitToInt(Copy(T, 17, 8), 2));
end;
end;
Inc(I, 4);
end else Inc(I);
end;
end; { Base64Decode }
 
回复人: zswang(伴水)(被黑中) (2001-12-12 22:50:52) 得0分
//再建议收录
http://www.csdn.net/expert/topic/384/384138.shtm
const
cCharCn: array[#32 .. #126] of string[2] =
(
{ }' ',{!}'!',{"}'"',{#}'#',{ }'$',{%}'%',{&}'&',{'}''',{(}'(',
{)}')',{*}'*',{+}'+',{,}',',{-}'-',{.}'。',{/}'/',{0}'0',{1}'1',
{2}'2',{3}'3',{4}'4',{5}'5',{6}'6',{7}'7',{8}'8',{9}'9',{:}':',
{;}';',{<}'<',{=}'=',{>}'>',{?}'?',{@}'@',{A}'A',{B}'B',{C}'C',
{D}'D',{E}'E',{F}'F',{G}'G',{H}'H',{I}'I',{J}'J',{K}'K',{L}'L',
{M}'M',{N}'N',{O}'O',{P}'P',{Q}'Q',{R}'R',{S}'S',{T}'T',{U}'U',
{V}'V',{W}'W',{X}'X',{Y}'Y',{Z}'Z',{[}'[',{/
 

Similar threads

I
回复
0
查看
603
import
I
I
回复
0
查看
503
import
I
I
回复
0
查看
481
import
I
I
回复
0
查看
729
import
I
顶部