Changeset 55 for trunk


Ignore:
Timestamp:
Dec 8, 2021, 3:49:19 PM (3 years ago)
Author:
chronos
Message:
  • Added: Support more file encodings for file open.
Location:
trunk
Files:
3 edited

Legend:

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

    r53 r55  
    634634msgstr "Očekávána vlastnost kontaktu"
    635635
     636#: ucontact.sexpectedvcardbegin
     637msgid "Expected vCard begin"
     638msgstr "Očekáván začátek vCard"
     639
    636640#: ucontact.sfax
    637641msgid "Fax"
     
    948952msgid "Invalid line length for encoded text"
    949953msgstr "Neplatná délka řádky kódovaného textu"
    950 
  • trunk/Languages/vCardStudio.po

    r53 r55  
    622622msgstr ""
    623623
     624#: ucontact.sexpectedvcardbegin
     625msgid "Expected vCard begin"
     626msgstr ""
     627
    624628#: ucontact.sfax
    625629msgid "Fax"
  • trunk/UContact.pas

    r54 r55  
    145145  UQuotedPrintable;
    146146
     147const
     148  VCardBegin = 'BEGIN:VCARD';
     149  VCardEnd = 'END:VCARD';
     150
    147151resourcestring
    148152  SVCardFile = 'vCard file';
    149153  SFoundPropertiesBeforeBlockStart = 'Found properties before the start of block';
    150154  SFoundBlockEndWithoutBlockStart = 'Found block end without block start';
     155  SExpectedVCardBegin = 'Expected vCard begin';
    151156  SFieldIndexNotDefined = 'Field index not defined';
    152157  SContactHasNoParent = 'Contact has no parent';
     
    610615var
    611616  I: Integer;
    612   J: Integer;
    613617  NameText: string;
    614618  Value2: string;
    615   Text: string;
    616619  LineIndex: Integer;
    617620  OutText: string;
     
    621624begin
    622625    with Output do begin
    623       Add('BEGIN:VCARD');
    624       for J := 0 to Properties.Count - 1 do
    625       with Properties[J] do begin
     626      Add(VCardBegin);
     627      for I := 0 to Properties.Count - 1 do
     628      with Properties[I] do begin
    626629        NameText := Name;
    627630        if Attributes.Count > 0 then
     
    657660        end;
    658661      end;
    659       Add('END:VCARD');
     662      Add(VCardEnd);
    660663    end;
    661664end;
     
    681684    end else
    682685    if ParseState = psNone then begin
    683       if Line = 'BEGIN:VCARD' then begin
     686      if Line = VCardBegin then begin
    684687        ParseState := psInside;
    685688      end else begin
    686         Parent.Error('Expected vCard begin', I + 1);
     689        Parent.Error(SExpectedVCardBegin, I + 1);
    687690        I := -1;
    688691        Break;
     
    690693    end else
    691694    if ParseState = psInside then begin
    692       if Line = 'END:VCARD' then begin
     695      if Line = VCardEnd then begin
    693696        ParseState := psFinished;
    694697        Inc(I);
     
    756759  try
    757760    Lines.LoadFromFile(FileName);
     761    if (Length(Lines.Text) > 0) and (Pos(VCardBegin, Lines.Text) = 0) then begin
     762      Lines.LoadFromFile(FileName, TEncoding.Unicode);
     763      if (Length(Lines.Text) > 0) and (Pos(VCardBegin, Lines.Text) = 0) then begin
     764        Lines.LoadFromFile(FileName, TEncoding.BigEndianUnicode);
     765      end;
     766    end;
    758767    I := LoadFromStrings(Lines);
    759768  finally
     
    882891  Lines := TStringList.Create;
    883892  Lines.LoadFromFile(FileName);
     893  if (Length(Lines.Text) > 0) and (Pos(VCardBegin, Lines.Text) = 0) then begin
     894    Lines.LoadFromFile(FileName, TEncoding.Unicode);
     895    if (Length(Lines.Text) > 0) and (Pos(VCardBegin, Lines.Text) = 0) then begin
     896      Lines.LoadFromFile(FileName, TEncoding.BigEndianUnicode);
     897    end;
     898  end;
    884899  try
    885900    I := 0;
Note: See TracChangeset for help on using the changeset viewer.