WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章SMS MMSSMS技术对于开发SMS初学者的,经常用到的几个函数

对于开发SMS初学者的,经常用到的几个函数
作者:佚名  来源:本站整理  发布时间:2005-7-13 10:57:39

/*****************************************************************************
* class : global function
* function : to_multibyte
* description: 把unicode转换成多字节
* parameters : char* strsm -- 要转换的unicode缓冲
* int nlength -- unicode缓冲的长度
* return : 转换后的多字节字串
* input :
* output :
* history : created by rongdian monday, april 29, 2002 11:03:15
* process :
******************************************************************************/
cstring to_multibyte(char* strsm, int nlength){
uint nlen = 0;
pbyte lpszm;
pbyte lpszw = new byte[nlength];
memcpy(lpszw, strsm, nlength);

for(int i = 0; i < nlength/2; i++)
*((unsigned short*)lpszw + i) = ntohs(*((unsigned short*)lpszw + i));

nlen = widechartomultibyte(936, wc_compositecheck,
(const unsigned short*)lpszw, nlength/2, null, 0, null, null);

lpszm = new byte[nlen+1];

nlen = widechartomultibyte(936, wc_compositecheck,
(const unsigned short*)lpszw, nlength/2, (char*)lpszm, nlen, null, null);

lpszm[nlen] = 0;
cstring cssm((lpctstr)lpszm, nlen);
delete lpszm;
delete lpszw;
return cssm;
}
/*****************************************************************************
* class : global function
* function : to_ucs2
* description: 把多字节转换成unicode
* parameters : char* strsm -- -- 要转换的多字节缓冲
* int nlength -- 多字节缓冲的长度
* return : 转换后的unicode字串
******************************************************************************/
cstring to_ucs2(char* strsm, int nlength){
cstring cssm((lpctstr)strsm, nlength);

pbyte lpszw = null;
uint nlen = 0;

nlen = multibytetowidechar(936, mb_precomposed,
(lpctstr)cssm, cssm.getlength(), null, 0);

lpszw = new byte[nlen * 2];

nlen = multibytetowidechar(936, mb_precomposed,
(lpctstr)cssm, cssm.getlength(), (lpwstr)lpszw, nlen);

for(uint i = 0; i < nlen; i ++)
*((unsigned short*)lpszw + i) = htons(*((unsigned short*)lpszw + i));

cstring csret((lpctstr)lpszw, nlen * 2);
delete lpszw;
return csret;
}

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码