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.

  • 相关阅读:
    Spring Boot
    AWS DynamoDB
    VBA读excel写xml
    WebSocket API 学习
    故障排除 Mybatis ORA-01000 和 本地缓存问题
    Java基础
    Java Tutorials Lambda表达式 翻译
    在代理环境中构建maven环境
    Pom
    我的JAVA笔记
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/13622498.html
Copyright © 2011-2022 走看看