如何URL编码和UTF-8编码

ss哥 2012-08-09 09:06:53
还有BASE64编码...给跪啦..新手
...全文
231 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
用户 昵称 2012-08-10
  • 打赏
  • 举报
回复
//**************************************
// unicode字符串转utf8字符串
// 返回大于0成功,小于0失败
//**************************************
int
ustr_u8str( WCHAR *unicodestr, char *utf8str )
{
int result = 0;
try
{
int needlen = WideCharToMultiByte( CP_UTF8, 0, unicodestr, -1, NULL, 0, NULL, NULL );
if( needlen < 0 )
{
return needlen;
}

result = WideCharToMultiByte( CP_UTF8, 0, unicodestr, -1, utf8str, needlen + 1, NULL, NULL );
if( result < 0 )
{
return result;
}
return ( result - 1 );
}
catch( ... )
{
ShowError();
}
return result;
}

用户 昵称 2012-08-10
  • 打赏
  • 举报
回复
csdn下载频道都有现成的代码,去下载并集成到软件中就行了。
  • 打赏
  • 举报
回复
base 64 : #include <atlenc.h>
utf-8: WideCharToMultiByte(CP_UTF8, ...)
url的因为是公司代码,不方便贴
believe_me 2012-08-09
  • 打赏
  • 举报
回复
开源的有很多啊,搜一下 url encode

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧