On 3/29/2012 10:55 AM, Nishchal A wrote:
I am trying to retrieve the IP of a machine with a non-ASCII name using the mentioned functions, I have noticed the following -
1. GetAddrInfoW - When I try to pass the wide char version of the machine name to this function, name resolution works properly.
2. getaddrinfo - When I try to pass the UTF8 version of the machine name (properly null terminated), name resolution does not work
Windows API doesn't do anything in UTF-8. If the name is representable in current system code page (CP_ACP), getaddrinfo might have a chance. But generally, wide versions of API functions (those that take UTF-16, usuarlly in the form of WCHAR*) are your
best bet.
Please note the msdn link for
GetAddrInfoW<http://msdn.microsoft.com/en-us/library/windows/desktop/ms738519(v=vs.85).aspx>mentions
that finally the UTF8 version goes on the wire.
That doesn't really matter. I doubt getaddrinfo sends its parameter directly onto the wire. I wouldn't be surprised if getaddrinfo converts its parameter from CP_ACP to Unicode (that is, UTF-16), then calls GetAddrInfoW.
* I noticed that the getaddrinfo does not send the same buffer and sends a slightly modifed version, what are the modifications for?
Modified in what way?
Igor Tandetnik