解决windows中文冲突

在工程当中添加UTF_text.h



#pragma once


#include "stdlib.h"

#include "string.h"

#ifdef WIN32


#define UTEXT(str) GBKToUTF8(str)

#include "..\cocos2d\external\win32-specific\icon\include\iconv.h"


static char g_GBKConvUTF8Buf[5000] = {0};

const char* GBKToUTF8(const char *strChar)

{

iconv_t iconvH;

iconvH = iconv_open("utf-8","gb2312");

if (iconvH == 0)

{

return NULL;

}

size_t strLength = strlen(strChar);

size_t outLength = strLength<<2;

size_t copyLength = outLength;

memset(g_GBKConvUTF8Buf, 0, 5000);


char* outbuf = (char*) malloc(outLength);

char* pBuff = outbuf;

memset( outbuf, 0, outLength);


if (-1 == iconv(iconvH, &strChar, &strLength, &outbuf, &outLength))

{

iconv_close(iconvH);

return NULL;

}

memcpy(g_GBKConvUTF8Buf,pBuff,copyLength);

free(pBuff);

iconv_close(iconvH);

return g_GBKConvUTF8Buf;

}

#else

#define UTEXT(str) str

#endif



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值