Changeset 46 for trunk


Ignore:
Timestamp:
Dec 3, 2021, 11:47:11 AM (3 years ago)
Author:
chronos
Message:
  • Fixed: Long BASE64 encoded lines were not automatically wrapped to limit max line length.
  • Fixed: Missing quoted-printable encoding for saving files.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/vCardStudio.cs.po

    r45 r46  
    1212"X-Generator: Poedit 3.0\n"
    1313
     14#: tcore.aabout.caption
     15msgid "About..."
     16msgstr "O aplikaci..."
     17
     18#: tcore.aexit.caption
     19msgid "Exit"
     20msgstr "Ukončit"
     21
     22#: tcore.afileclose.caption
     23msgid "Close"
     24msgstr "Zavřít"
     25
     26#: tcore.afilemerge.caption
     27msgid "Merge..."
     28msgstr "Sloučit..."
     29
     30#: tcore.afilenew.caption
     31msgid "New"
     32msgstr "Nový"
     33
     34#: tcore.afileopen.caption
     35msgid "Open..."
     36msgstr "Otevřít..."
     37
     38#: tcore.afileopenrecent.caption
     39msgctxt "tcore.afileopenrecent.caption"
     40msgid "Open recent"
     41msgstr "Otevřít nedávné"
     42
     43#: tcore.afilesave.caption
     44msgid "Save"
     45msgstr "Uložit"
     46
     47#: tcore.afilesaveas.caption
     48msgid "Save as..."
     49msgstr "Uložit jako..."
     50
     51#: tcore.afindduplicate.caption
     52msgctxt "tcore.afindduplicate.caption"
     53msgid "Find duplicities"
     54msgstr "Najít duplikáty"
     55
     56#: tcore.agenerate.caption
     57msgctxt "tcore.agenerate.caption"
     58msgid "Generate contacts"
     59msgstr "Generovat kontakty"
     60
     61#: tcore.ahomepage.caption
     62msgid "Home page"
     63msgstr "Domovská stránka"
     64
     65#: tcore.applicationinfo1.description
     66msgid "vCard files management tool"
     67msgstr "Nástroj pro správu souborů vCard"
     68
     69#: tcore.asettings.caption
     70msgctxt "tcore.asettings.caption"
     71msgid "Settings"
     72msgstr "Nastavení"
     73
    1474#: tformcontact.aphotoload.caption
    1575msgid "Load from file"
  • trunk/Languages/vCardStudio.po

    r45 r46  
    11msgid ""
    22msgstr "Content-Type: text/plain; charset=UTF-8"
     3
     4#: tcore.aabout.caption
     5msgid "About..."
     6msgstr ""
     7
     8#: tcore.aexit.caption
     9msgid "Exit"
     10msgstr ""
     11
     12#: tcore.afileclose.caption
     13msgid "Close"
     14msgstr ""
     15
     16#: tcore.afilemerge.caption
     17msgid "Merge..."
     18msgstr ""
     19
     20#: tcore.afilenew.caption
     21msgid "New"
     22msgstr ""
     23
     24#: tcore.afileopen.caption
     25msgid "Open..."
     26msgstr ""
     27
     28#: tcore.afileopenrecent.caption
     29msgctxt "tcore.afileopenrecent.caption"
     30msgid "Open recent"
     31msgstr ""
     32
     33#: tcore.afilesave.caption
     34msgid "Save"
     35msgstr ""
     36
     37#: tcore.afilesaveas.caption
     38msgid "Save as..."
     39msgstr ""
     40
     41#: tcore.afindduplicate.caption
     42msgctxt "tcore.afindduplicate.caption"
     43msgid "Find duplicities"
     44msgstr ""
     45
     46#: tcore.agenerate.caption
     47msgctxt "tcore.agenerate.caption"
     48msgid "Generate contacts"
     49msgstr ""
     50
     51#: tcore.ahomepage.caption
     52msgid "Home page"
     53msgstr ""
     54
     55#: tcore.applicationinfo1.description
     56msgid "vCard files management tool"
     57msgstr ""
     58
     59#: tcore.asettings.caption
     60msgctxt "tcore.asettings.caption"
     61msgid "Settings"
     62msgstr ""
    363
    464#: tformcontact.aphotoload.caption
  • trunk/UContact.pas

    r45 r46  
    691691  NameText: string;
    692692  Value2: string;
     693  Text: string;
     694  LineIndex: Integer;
     695  OutText: string;
     696  LinePrefix: string;
     697const
     698  MaxLineLength = 73;
    693699begin
    694700  inherited;
     
    705711        if Encoding <> '' then begin
    706712          Value2 := GetEncodedValue;
    707           NameText := NameText + ';' + Encoding;
     713          NameText := NameText + ';ENCODING=' + Encoding;
    708714        end else Value2 := Value;
    709715        if Pos(LineEnding, Value2) > 0 then begin
     
    715721          Add('');
    716722        end else begin
    717           Add(NameText + ':' + Value2);
     723          OutText := NameText + ':' + Value2;
     724          LineIndex := 0;
     725          LinePrefix := '';
     726          while True do begin
     727            if Length(OutText) > MaxLineLength then begin
     728              if (LineIndex > 0) and (LinePrefix = '') then LinePrefix := ' ';
     729              Add(LinePrefix + Copy(OutText, 1, MaxLineLength));
     730              System.Delete(OutText, 1, MaxLineLength);
     731              Inc(LineIndex);
     732              Continue;
     733            end else begin
     734              Add(LinePrefix + OutText);
     735              Break;
     736            end;
     737          end;
     738          if LinePrefix <> '' then Add('');
    718739        end;
    719740      end;
  • trunk/UQuotedPrintable.pas

    r45 r46  
    2929  Keeper: Boolean;
    3030  Abort: Boolean;
    31   BufStream: TMemoryStream;
     31  InStream: TMemoryStream;
    3232  OutStream: TMemoryStream;
    3333begin
    3434  Result := '';
    35   BufStream := TMemoryStream.Create;
     35  InStream := TMemoryStream.Create;
    3636  OutStream := TMemoryStream.Create;
    3737  try
    3838  if Text <> '' then begin
    39     BufStream.Write(Text[1], Length(Text));
    40     BufStream.Position := 0;
     39    InStream.Write(Text[1], Length(Text));
     40    InStream.Position := 0;
    4141  end;
    4242  Abort := False;
     
    4848  { Skip any CR/LF's to get to the encoded stuff }
    4949  while True do begin
    50     if BufStream.Read(Char(InBuf[0]), 1) = 0then
     50    if InStream.Read(Char(InBuf[0]), 1) = 0then
    5151      Exit;
    5252    if ((InBuf[0] <> $0D) and (InBuf[0] <> $0A)) then begin
     
    7070      if (I > High(InBuf)) then
    7171        raise Exception.Create(SLineLengthErr);
    72       if BufStream.Read(Char(InBuf[I]), 1) = 0 then
     72      if InStream.Read(Char(InBuf[I]), 1) = 0 then
    7373        Break;
    7474      case InBuf[I] of
     
    195195  SetLength(Result, OutStream.Size);
    196196  OutStream.Position := 0;
    197   OutStream.Read(Result[1], Length(Result));
     197  if OutStream.Size > 0 then
     198    OutStream.Read(Result[1], Length(Result));
    198199  finally
    199200    OutStream.Free;
    200     BufStream.Free;
     201    InStream.Free;
    201202  end;
    202203end;
    203204
    204205function EncodeQuotedPrintable(Text: string): string;
     206var
     207  O, W: Integer;
     208  WordBuf, OutBuf: array[0..80] of AnsiChar;
     209  CurChar: AnsiChar;
     210  Abort: Boolean;
     211  InStream: TStream;
     212  OutStream: TMemoryStream;
     213
     214  procedure SendLine;
     215  begin
     216    if (OutBuf[O - 1] = #9) or (OutBuf[O - 1] = #32) then begin
     217      OutBuf[O] := '=';
     218      Inc(O);
     219    end;
     220    OutStream.Write(OutBuf, O);
     221    FillChar(OutBuf, SizeOf(OutBuf), #0);
     222    O := 0;
     223  end;
     224
     225  procedure AddWordToOutBuf;
     226  var
     227    J : Integer;
     228  begin
     229    if (O + W) > 74 then SendLine;
     230    for J := 0 to (W - 1) do begin
     231      OutBuf[O] := WordBuf[J];
     232      Inc(O);
     233    end;
     234    W := 0;
     235  end;
     236
     237  procedure AddHexToWord(B : Byte);
     238  const
     239    HexDigits : array[0..$F] of AnsiChar = '0123456789ABCDEF';
     240  begin
     241    if W > 73 then AddWordToOutBuf;
     242    WordBuf[W] := '=';
     243    WordBuf[W + 1] := HexDigits[B shr 4];
     244    WordBuf[W + 2] := HexDigits[B and $F];
     245    Inc(W, 3)
     246  end;
     247
    205248begin
    206   Result := Text;
     249  Result := '';
     250  InStream := TMemoryStream.Create;
     251  OutStream := TMemoryStream.Create;
     252  try
     253    if Text <> '' then begin
     254      InStream.Write(Text[1], Length(Text));
     255      InStream.Position := 0;
     256    end;
     257
     258    Abort := False;
     259    O := 0;
     260    W := 0;
     261    FillChar(OutBuf, SizeOf(OutBuf), #0);
     262    while (InStream.Read(CurChar, 1) = 1) and not Abort do begin
     263      if (Ord(CurChar) in [33..60, 62..126]) then begin
     264        WordBuf[W] := CurChar;
     265        Inc(W);
     266        if W > 74 then AddWordToOutBuf;
     267      end else if (CurChar = ' ') or (CurChar = #9) then begin
     268        WordBuf[W] := CurChar;
     269        Inc(W);
     270        AddWordToOutBuf;
     271      end else if (CurChar = #13) then begin
     272        AddWordToOutBuf;
     273        SendLine;
     274      end else if (CurChar = #10) then begin
     275        { Do nothing }
     276      end else begin
     277        AddHexToWord(Byte(CurChar));
     278      end;
     279    end;
     280    AddWordToOutBuf;
     281    OutStream.Write(OutBuf, O);
     282    SetLength(Result, OutStream.Size);
     283    OutStream.Position := 0;
     284    if OutStream.Size > 0 then
     285      OutStream.Read(Result[1], Length(Result));
     286  finally
     287    OutStream.Free;
     288    InStream.Free;
     289  end;
    207290end;
    208291
Note: See TracChangeset for help on using the changeset viewer.