1. Wrtiting string to TMemoryStream - Pointer to string
2. 现有 Delphi 项目迁移到 Tiburon 中的注意事项
擴充的TStreamEx,在D7, Delphi XE下都可正確使用,只能說歪國人真是太厲害了,學習!
procedure TStreamEx.WriteString(const data: string); var len: cardinal; oString: UTF8String; begin oString := UTF8String(data); len := length(oString); self.WriteBuffer(len, 4); if len > 0 then self.WriteBuffer(oString[1], len); end; procedure TStreamEx.ReadString(const data: string); var len: cardinal; iString: UTF8String; begin self.ReadBuffer(len, 4); if len > 0 then begin SetLength(iString, len); self.ReadBuffer(iString[1], len); result := string(iString); end else result := ''; end;
沒有留言:
張貼留言