treo
V2EX  ›  问与答

你能不查msdn就说出LPSTR LPCSTR LPWSTR LPCWSTR LPTSTR LPCTSTR的区别吗?

  •  
  •   treo · Jun 6, 2012 · 5373 views
    This topic created in 5114 days ago, the information mentioned may be changed or developed.
    这年头在还有几个人写ANSI的win32程序?实际用到的只有LPWSTR和LPCWSTR吧。。为什么各类win32编程教材里还在讲让新手头晕的种种string types
    4 replies    1970-01-01 08:00:00 +08:00
    avatasia
        1
    avatasia  
       Jun 6, 2012
    LPSTR 正常使用
    LPCSTR 常量
    LPWSTR 宽字符
    LPCWSTR 常量宽字符
    LPTSTR 根据编译选项选用LPSTR或者LPWSTR
    LPCTSTR 同上

    很简单的。
    建议都用LPCTSTR,或者是stl::string.
    如果用LPSTR, 可以考虑使用utf-8编码。
    碰到中文乱码这种事情很头疼。
    Echoldman
        2
    Echoldman  
       Jun 6, 2012
    历史遗留问题,打补丁式的解决方案,就搞成这样了。
    oci
        3
    oci  
       Jun 6, 2012
    很难吗?W 表示宽,T 表示窄宽通用,C 表示常量,Windows API 那么有规律
    ayang23
        4
    ayang23  
       Jun 6, 2012
    这得感谢匈牙利人。目前只用LPWSTR,全部unicode以免出错。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2802 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:55 · PVG 17:55 · LAX 02:55 · JFK 05:55
    ♥ Do have faith in what you're doing.