您现在的位置是:首页 >

字符串改成日期格式 Delphi把流中的字符串转换为UTF格式

火烧 2022-12-24 03:53:47 1059
Del hi把流中的字符串转换为UTF格式   本例效果图   =180 gt   代码文件  u it U it   i terface  u e   Wi dow Me age Sy Util V

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  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码