posts - 274,  comments - 1258,  trackbacks - 0

常用的宽字符函数
由于Windows NT/2000/XP采用的是Unicode字符编码,字符都是双字节的。所以在MFC编程中,一般需要使用双字节的字符类型wchar_t和对应的字符串及其指针类型LPCWSTR和LPCTSTR,并在常数字符串前添加了L转换符,串长计算函数不能用strlen而改用wcslen,串格式打印函数也不能用sprintf,而是改用swprintf。
wchar_t类型,在标准C++中为内置的数据类型和关键字;在C99标准中则为typedef类型,其等价的数据类型与具体的实现有关,在Win32和VC中定义为:
typedef  unsigned short  wchar_t;
下面是若干常用的宽字符函数(包含在ISO C99 / ISO C++的标准库中):
#include <wchar.h>
size_t wcslen(const wchar_t *s);
int wprintf(const wchar_t * restrict format, ...);
int wscanf(const wchar_t * restrict format, ...);
int swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...);
int swscanf(const wchar_t * restrict s, const wchar_t * restrict format, ...);
long int wcstol(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
float wcstof(const wchar_t * restrict nptr, wchar_t ** restrict endptr);
double wcstod(const wchar_t * restrict nptr, wchar_t ** restrict endptr);

#include <stdlib.h>
errno_t _itow_s( int value, wchar_t *buffer, size_t sizeInCharacters, int radix );
errno_t _ultow_s( unsigned long value, wchar_t *str, size_t sizeOfstr, int radix );

---
本文章使用开源内容管理kicoy发布

转载自李才伟老师的课件

posted on 2006-06-12 11:42 踏雪赤兔 阅读(1153) 评论(3)  编辑 收藏 引用 所属分类: 速查手册

FeedBack:
# re: 常用的宽字符函数
2008-10-21 10:50 | ant
哈。你也是lcw的学生吗。。赫赫,。他的课件血牛逼~  回复  更多评论
  
# re: 常用的宽字符函数
2008-10-22 10:55 | 踏雪赤兔
系啊系啊  回复  更多评论
  
# re: 常用的宽字符函数
2009-06-09 20:42 |
百度‘宽字符 函数’时,见此熟悉结果,甚喜
Rank 3  回复  更多评论
  
只有注册用户登录后才能发表评论。

百度空间| 见闻日记| 编程感悟
我的twitter


LOGO

自我介绍:百度厂基础平台车间的一名挨踢民工。擅长C++、算法、语言设计、分布式计算,也用过Java,Python, PHP,JS/AS等语言开发。请关注我的twitter (免翻墙版) 发QQ消息


添加到收藏夹 Locations of visitors to this page

常用链接

随笔分类(300)

随笔档案(274)

文章分类(38)

相册

收藏夹(54)

与博主互动

博客手拉手

搜索

  •  

积分与排名

  • 积分 - 392687
  • 排名 - 10

最新评论

阅读排行榜

评论排行榜