我正在尝试在 Wince 6.0 中将 C# 代码实现为 C/C++(无需安装 .NET Framework)。
在这段C#代码中,使用了IdnMapping::GetAscii方法,也需要在C/C++中进行转换。 http://msdn.microsoft.com/en-us/library/system.globalization.idnmapping.getascii.aspx
需要一个与 IdnMapping::GetAscii 等效的函数。
thnx 提示和帮助 =)
问候..
我正在尝试在 Wince 6.0 中将 C# 代码实现为 C/C++(无需安装 .NET Framework)。
在这段C#代码中,使用了IdnMapping::GetAscii方法,也需要在C/C++中进行转换。 http://msdn.microsoft.com/en-us/library/system.globalization.idnmapping.getascii.aspx
需要一个与 IdnMapping::GetAscii 等效的函数。
thnx 提示和帮助 =)
问候..
You could try this:
Foreach sign in your string make a static_cast and copy this to your ASCII-string
char* GetASCII(const wchar_t* wstr) { int count = wcslen(wstr); char* ascii = new char[count + 1];
wchar_t* pwchr = const_cast<wchar_t*> (&wstr[0]);
for(int j = 0; j < count; ++j)
{
ascii [j] = static_cast<char> (*pwchr);
pwchr++;
}
ascii [count] = '\0';
return ascii ;
}
“ascii”字符串在 punycode 中。
所以你需要寻找用于punycode转换的示例代码,例如,https://www.example-code.com/cpp/punycode.asp