0

我正在尝试在 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 提示和帮助 =)

问候..

4

2 回答 2

0

You could try this:

  1. Getting length of string
  2. Initialize a new Unicode String with the pointer on the first element of your input
  3. 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 ;
    

    }

于 2012-12-13T09:06:28.327 回答
0

“ascii”字符串在 punycode 中。

所以你需要寻找用于punycode转换的示例代码,例如,https://www.example-code.com/cpp/punycode.asp

于 2017-05-11T21:08:21.940 回答