zoukankan      html  css  js  c++  java
  • 关于不同类型字符的转换

    一、string转为ansistring
    1、直接赋值 (有警告)
    2、ansistring()类型强制转换。(无警告)

    二、ansistring 转为string

    1、直接赋值 (有警告)
    2、string()类型强制转换。(无警告)

    三、string 转为Tbytes

    1、bytes:= bytesof(str) 已转为ansi编码
    2、bytes:= widebytesof(str) UNICODE 编码

    四、ansistring 转为Tbytes

    1、bytes:= bytesof(str) ansi编码
    2、bytes:= widebytesof(string(str)) UNICODE 编码

    五、Tbytes 转为string

    1、 str:=stringof(bytes) Tbytes 为ansi编码
    2、 str:=widestringof(bytes) Tbytes 为unicode编码

    六、PChar转String

    用StrPas函数,StrPas(PChar):AnsiString;

    ============================================

    Indy10 IdudpServer获取字符串string类型数据,采用Read事件,TIdBytes类型的使用,支持中文,双字节。

    indy10变化相当大,都不会用了。开始被Tidbytes这个类型搞晕。

    Indy10 IdudpServer使用

    uses IDGlobal;

    Read事件主要代码:

    s:=enutf8.getting(adata);

  • 相关阅读:
    记忆的永恒
    放弃我是你的错
    献给我逝去的长辈们清明
    思维的局限,穷人为什么会穷?
    借我一生
    陪你到老
    风雨路途
    人生的十二大财富
    怀才不遇
    javascript变量
  • 原文地址:https://www.cnblogs.com/jieling/p/6104573.html
Copyright © 2011-2022 走看看