掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
文字列操作 (ID:7460)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
>jokさん ByteToHexStrは、 IntToHex(Integer(p^), 2) + ' ' とできますね。 私の場合、こんな感じです。jokさんと大差ありません。 FileStreamで1バイトずつ取り込んでいるので、こっちの方が遅いかも。 実際にやる場合は、適当な量のバッファを用意して、バッファ単位で処理した方がよいです。TMemoryStreamで読み込む場合、数GBになると問題が出てきそうです。 # スワップメモリが大量発生しそう var i: integer; fs: TFileStream; buf: byte; str: String; cnt: Integer; st, et: LongInt; begin st := GetTickCount; fs := nil; str := ''; cnt := 0; try fs := TFileStream.Create('C:\test.dat', fmOpenRead); while fs.Read(buf, 1) > 0 do begin str := str + IntToHex(Integer(buf), 2) + ' '; Inc(cnt); if cnt > 15 then begin str := str + #13#10; cnt := 0; end; end; Editor1.Lines.Text := str; finally et := GetTickCount; if Assigned(fs) then fs.Free; ShowMessage(IntToStr(et - st) + ' ms'); end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.