delphi获取各种编码的识别符


本文整理自网络,侵删。

 下面是常用编码的识别符, 在 Delphi(2009) 中如何获取呢?
Unicode: FF FE; BigEndianUnicode: FE FF; UTF8: EF BB BF
--------------------------------------------------------------------------------


var
bs: TBytes;
b: Byte;
str: string;
begin
{只有 Unicode、BigEndianUnicode、UTF8 编码有识别符}
bs := TEncoding.Unicode.GetPreamble;
str := '';
for b in bs do str := Format('%s %x', [str, b]);
ShowMessage(str); {FF FE}

bs := TEncoding.BigEndianUnicode.GetPreamble;
str := '';
for b in bs do str := Format('%s %x', [str, b]);
ShowMessage(str); {FE FF}

bs := TEncoding.UTF8.GetPreamble;
str := '';
for b in bs do str := Format('%s %x', [str, b]);
ShowMessage(str); {EF BB BF}

{ASCII、UTF7 和 Default(默认编码) 没有识别符}
bs := TEncoding.ASCII.GetPreamble;
str := '';
for b in bs do str := Format('%s %x', [str, b]);
ShowMessage(str); {无}

bs := TEncoding.UTF7.GetPreamble;
str := '';
for b in bs do str := Format('%s %x', [str, b]);
ShowMessage(str); {无}

bs := TEncoding.Default.GetPreamble;
str := '';
for b in bs do str := Format('%s %x', [str, b]);
ShowMessage(str); {无}
end;

相关阅读 >>

Delphi rest客户端程序

Delphi textfile utf8编码读写

Delphi datetimepicker控件日期格式

Delphi 为数字补充前缀0

Delphi html转义

Delphi 如何从html格式的字符串中提取纯文本?

Delphi 提高unigui开发效率的两个方法

Delphi 如何将颜色值转换为html格式?

orangeui作者开源作品

Delphi 如何将颜色值转换为灰度颜色值?

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



打赏

取消

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

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

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

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

评论

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