这个得到的line字符串只要是中文就是乱码 该怎么弄呀?
代码程序不是我写的
extern "C" {
JNIEXPORT jstring JNICALL Java_TXT_TextDemo_GetPath
(JNIEnv * v, jclass TestNative)
{
jstring r = NULL;
int i = 0;
char *c = new char[100];
char line[260];
char *utf;
LPWSTR p = GetCommandLine();
wchar_t *cur = p;
char *des = line;
unsigned int x = 0;
// convert wchar_t* to char*
// 注意这个函数不支持中文,因为没有将GBK编码转UTF,网上找GBKtoUTF8
for(;*cur!=0;cur++) {
x = (unsigned int)*cur;
*des = (char)(x%256); des++;
if(x>=256) {*des = (char)(x/256); des++;}
}
*des = 0;
r=v->NewStringUTF(line);
//r = v->NewString
return r;
}
} // end of extern
#endif
精慕HU