Changeset 55 for trunk/UContact.pas
- Timestamp:
- Dec 8, 2021, 3:49:19 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UContact.pas
r54 r55 145 145 UQuotedPrintable; 146 146 147 const 148 VCardBegin = 'BEGIN:VCARD'; 149 VCardEnd = 'END:VCARD'; 150 147 151 resourcestring 148 152 SVCardFile = 'vCard file'; 149 153 SFoundPropertiesBeforeBlockStart = 'Found properties before the start of block'; 150 154 SFoundBlockEndWithoutBlockStart = 'Found block end without block start'; 155 SExpectedVCardBegin = 'Expected vCard begin'; 151 156 SFieldIndexNotDefined = 'Field index not defined'; 152 157 SContactHasNoParent = 'Contact has no parent'; … … 610 615 var 611 616 I: Integer; 612 J: Integer;613 617 NameText: string; 614 618 Value2: string; 615 Text: string;616 619 LineIndex: Integer; 617 620 OutText: string; … … 621 624 begin 622 625 with Output do begin 623 Add( 'BEGIN:VCARD');624 for J:= 0 to Properties.Count - 1 do625 with Properties[ J] do begin626 Add(VCardBegin); 627 for I := 0 to Properties.Count - 1 do 628 with Properties[I] do begin 626 629 NameText := Name; 627 630 if Attributes.Count > 0 then … … 657 660 end; 658 661 end; 659 Add( 'END:VCARD');662 Add(VCardEnd); 660 663 end; 661 664 end; … … 681 684 end else 682 685 if ParseState = psNone then begin 683 if Line = 'BEGIN:VCARD'then begin686 if Line = VCardBegin then begin 684 687 ParseState := psInside; 685 688 end else begin 686 Parent.Error( 'Expected vCard begin', I + 1);689 Parent.Error(SExpectedVCardBegin, I + 1); 687 690 I := -1; 688 691 Break; … … 690 693 end else 691 694 if ParseState = psInside then begin 692 if Line = 'END:VCARD'then begin695 if Line = VCardEnd then begin 693 696 ParseState := psFinished; 694 697 Inc(I); … … 756 759 try 757 760 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; 758 767 I := LoadFromStrings(Lines); 759 768 finally … … 882 891 Lines := TStringList.Create; 883 892 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; 884 899 try 885 900 I := 0;
Note:
See TracChangeset
for help on using the changeset viewer.