在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1、将汉字编码: var s: widestring; i, j: integer; tmpstr: string; c2: WideChar; begin for j := 0 to Memo2.lines.count - 1 do begin tmpstr := ''; s := Memo2.Lines[j]; for i := 1 to length(s) do begin tmpstr := tmpstr + inttostr(ord(s[i])) + ','; end; end; Memo1.Lines.Add(tmpstr + '#'); end; 2、根据汉字编码生成二维码: const sFileName = 'QRCode.bmp'; var oBmp: TBitmap; begin CreateQRCode(AnsiToUtf8(memo1.Lines.Text), 0, 1, 3); if FileExists(sFileName) then begin oBmp := TBitmap.Create; oBmp.LoadFromFile(sFileName); image1.Picture.Assign(oBmp); FreeAndNil(oBmp); end; end;
3、将编码转换成汉字(解码) var tmplist: TStringList; tmpstr: string; j, i: Integer; c2: WideChar; begin try tmplist := TStringList.Create(); tmpstr := Copy(Self.Edit1.Text, 0, Length(Self.Edit1.Text) - 1); tmplist := SplitString(tmpstr, ','); for j := 0 to tmplist.Count - 1 do begin if tmplist[j] <> '' then begin i := StrToInt(tmplist[j]); c2 := widechar(i); Memo1.Lines.Add(c2) end; end; finally FreeAndNil(tmplist); end; end; 4、用到的splitstring函数: function SplitString(const Source, ch: string): TStringList; var temp: string; i: Integer; begin Result := TStringList.Create; //如果是空自符串则返回空列表 if Source = '' then exit; temp := Source; i := pos(ch, Source); while i <> 0 do begin Result.add(copy(temp, 0, i - 1)); Delete(temp, 1, i); i := pos(ch, temp); end; Result.add(temp); end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论