user206705
user206705

Reputation:

Why does MSDN advise use of unicode functions over ansi functions for winsock calls?

MSDN advises:

The getaddrinfo function is the ANSI version of a function that provides protocol-independent translation from host name to address. The Unicode version of this function is GetAddrInfoW. Developers are encouraged to use the GetAddrInfoW Unicode function rather than the getaddrinfo ANSI function.

Encouragement is fine and all, but is there any reason to do this? I mean, can hostnames contain non-ansi characters? If so, is this a feature exclusive to IPv6, or can IPv4 hostnames also contain unicode characters?

Upvotes: 1

Views: 311

Answers (2)

Remy Lebeau
Remy Lebeau

Reputation: 598011

Microsoft is just trying to get everyone away from Ansi in general, that's all. They recommend using Unicode for everything, especially since Windows itself is based on Unicode (and has been for a long long time). But yes, as Jason said, hostnames can contain Unicode characters via Punycode encoding, which is backwards compatible with the existing Ansi-based DNS system.

Upvotes: 3

Jason Malinowski
Jason Malinowski

Reputation: 19031

DNS supports what are known as "internationalized domain names" via an encoding scheme called Punycode. So yes, hostnames can contain Unicode characters. It has nothing to do with IPv4 or IPv6, since that's a different network protocol entirely.

Upvotes: 2

Related Questions