delphi 判断 文本文件 utf-8 BOM头


本文整理自网络,侵删。

 
function UTF8FileBOM(const FileName: string): boolean;
var
  txt: file;
  bytes: array[0..2] of byte;
  amt: integer;
begin
  FileMode := fmOpenRead;
  AssignFile(txt, FileName);
  Reset(txt, 1);
  try
    BlockRead(txt, bytes, 3, amt);
    result := (amt=3) and (bytes[0] = $EF) and (bytes[1] = $BB) and (bytes[2] = $BF);
  finally    
    CloseFile(txt);
  end;
end;




https://bbs.csdn.net/topics/390275052

相关阅读 >>

Delphi之屏幕和窗口的坐标

Delphi xe6 利用fastmm4检测内存泄漏

Delphi ios 保持设备开机状态

Delphi 动态数组的使用

Delphi 的运算符列表

快速查询posex与posrightex

Delphi [数据库连接字符串] access 连接字符串

Delphi中move 函数额用法

Delphi读取网页源文件和获取字符串

Delphi瞬间消除无用托盘图标(刷新托盘)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...