zoukankan      html  css  js  c++  java
  • delphi2009及以上版本中String与PAnsiChar转换

    相关资料:
    http://blog.sina.com.cn/s/blog_140f86bd70102xs49.html
     
    在winsock编程中,使用api函数 inet_addr将ip地址转换成网络字节序时,传入参数类型为直接将string转换成PAnsiChar类型,转换出来的网络字节有错误,无法使用该ip,解决办法如下:

    所有的原生字符串类型String转PAnsiChar都需要经过AnsiString过渡
    strAnsi:= PAnsiChar(AnsiString(str));

     
    其原因如下:

    In D2009 and later: yes, there is. PChar is a pointer to a Char which is a unicode character (a WideChar). And PAnsiChar is a pointer to a AnsiChar, which is - as the name implies - an ANSI character.

     

    EDIT: For pre-2009 versions of Delphi PChar and PAnsiChar are exactly the same. They both point to an (Ansi) character.

  • 相关阅读:
    哈希表(hash)
    并查集
    trie树(字典树)
    单调队列(滑动窗口)
    单调栈
    用数组实现栈与队列
    数组实现双链表
    数组实现单链表
    区间合并
    离散化
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/13622498.html
Copyright © 2011-2022 走看看