tw3758.pp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. { Source provided for Free Pascal Bug Report 3758 }
  2. { Submitted by "Martin Schreiber" on 2005-03-07 }
  3. { e-mail: }
  4. program project1;
  5. {$mode objfpc}{$H+}
  6. uses
  7. Classes, SysUtils;
  8. type
  9. ttestcomp = class(tcomponent)
  10. private
  11. fwstr: widestring;
  12. published
  13. property wstr: widestring read fwstr write fwstr;
  14. end;
  15. var
  16. stream1,stream2: tmemorystream;
  17. f: tfilestream;
  18. testcomp1,testcomp2: ttestcomp;
  19. str1: widestring;
  20. begin
  21. setlength(str1,2);
  22. str1[1]:= widechar($1f00);
  23. str1[2]:= widechar($203);
  24. stream1:= tmemorystream.create;
  25. stream2:= tmemorystream.create;
  26. testcomp1:= ttestcomp.create(nil);
  27. testcomp2:= ttestcomp.create(nil);
  28. try
  29. testcomp1.wstr:= str1;
  30. stream1.writecomponent(testcomp1);
  31. stream1.position:= 0;
  32. objectbinarytotext(stream1,stream2);
  33. stream1.clear;
  34. stream2.position:= 0;
  35. f:= tfilestream.create('test.txt',fmcreate);
  36. f.copyfrom(stream2,0);
  37. f.free;
  38. stream2.position:= 0;
  39. objecttexttobinary(stream2,stream1);
  40. stream1.position:= 0;
  41. stream1.readcomponent(testcomp2);
  42. if testcomp2.wstr = str1 then begin
  43. writeln('OK');
  44. end
  45. else begin
  46. writeln('Error');
  47. end;
  48. finally
  49. stream1.free;
  50. stream2.free;
  51. testcomp1.free;
  52. testcomp2.free;
  53. deletefile('test.txt');
  54. end;
  55. end.