字符串改成日期格式 Delphi把流中的字符串转换为UTF格式
Delphi把流中的字符串转换为UTF格式
本例效果图

=180>
代码文件
unit Unit ;
interface
uses Windows Messages SysUtils Variants Classes Graphics Controls Forms Dialogs StdCtrls;
type TForm = class(TForm) Button : TButton; Memo : TMemo; procedure Button Click(Sender: TObject); procedure FormCreate(Sender: TObject); end;
var Form : TForm ;
implementation
{$R * dfm}
procedure TForm Button Click(Sender: TObject);var stream stream : TStringStream; b: Byte; bs: string;begin {建立第一个流 使用默认的双字节编码; 流中的数据是 Memo 中的字符串} stream := TStringStream Create(Memo Text );
{把第一个流的十六进制编码显示在 Memo 中} bs := ; for b in stream Bytes do bs := Format(bs + % x [b]); Memo Lines Add(bs);
{建立第二个流 用 UTF 编码; 还是基于第一个流中的字符串} stream := TStringStream Create(stream DataString TEncoding UTF );
{把第二个流的十六进制编码显示在 Memo 中} bs := ; for b in stream Bytes do bs := Format(bs + % x [b]); Memo Lines Add(bs);
stream Free; stream Free;end;
procedure TForm FormCreate(Sender: TObject);begin Memo Align := alTop; Memo ScrollBars := ssBoth; Memo Text := 万一的 Delphi 博客 ;end;
end
窗体文件:
lishixinzhi/Article/program/Delphi/201311/24665