On one of our internal aliases, someone asked the following question:
[i]s there any API that I can use to do case insensitive comparison of two OEM strings? (NetBIOS names are encoded in OEMCP.)
Wow, that’s question was a blast from the past. Windows Networking before NT 3.1 (which includes NetBIOS) had this undeclared and undefined construct called the “network codepage”. Essentially an administrator was required to decide what the single codepage was for every computer on the network, and ensure that all computers were running in the same codepage.
History lesson: A NetBIOS “name” is actually a series of 16 octets, and as such can only be compared by memcmp. In DOS 3.1 (1984, which was before DNS was designed), Microsoft layered the concept of a “computer name” on top of a NetBIOS name. It did that by uppercasing (using the internal DOS case mapping table) the computername being contacted and setting that as the NetBIOS name on the PC Lan Adapter.
When DOS 3.3 came out, it’s major innovation was to borrow the concept of a “code page” from IBM’s mainframe systems. Essentially it meant that instead of the case mapping table being hard coded into the OS, it was loaded by an application (chcp). Note that there was still only one codepage per system, and that codepage case maping was still per-machine. As such, if you have machines with more than one codepage on the network, you’re likely to have issues if those computernames contain internationalized characters. We received complaints from customers at the time about this Microsoft’s answer was essentially “don’t use international characters in your computer names”.
Windows 1.0 added a second codepage to DOS, called the “ANSI Codepage” (or Windows Codepage). Windows applications used this codepage, while MS-DOS continued to use the codepage loaded by chcp. This MS-DOS codepage became known as the OEM codepage.
Fast forward 8 years when NT 3.1 came out. NT 3.1 still had a single OEM codepage, but added support for Unicode. Millions rejoiced, especially those customers who got pissed off by our answer from 8 years earlier. NT 3.1’s rules were slightly better than MS-DOS’s rules. NT 3.1 took the Unicode computername and uppercased it using the current active codepage. It then converted that uppercase Unicode string to the single OEM codepage and used that series of octets as the computer name.
The customers who had been pissed off by our answer 8 years earlier were somewhat happier, but not very much. If you have more than one codepage on the network, you STILL can have issues because the upper casing rules are still per-machine, and characters uppercase differently depending on the character set on the machine. Essentially NT 3.1 helped things for some computer names, but we STILL had this undefined, undeclared concept of a “network codepage”.
As far as I know, this is still the state of the world w.r.t. NetBIOS names.
In general, you’re better off matching two computernames (i.e. before the Unicode to OEM conversion) before you try matching two NetBIOS names).
If you were to root cause the problem, the issue is that most networking protocols were not designed with internationalization in mind – as a result, most of them seem to have an assumption that the both sides of the network transaction are running with the same internationalization rules. It’s not surprising, honestly – I was involved in some of the efforts to define internationalization extensions to the IMAP4 protocol and it turned into a swamp pit (the problem is that at the time (late 1990s) there weren’t many international standards for case folding and thus the group was stuck with essentially punting the problem to the host OS, which wasn’t considered a good solution because many OS’s had limited support for supporting multiple case folding tables). As a result, networking protocols that specify case insensitivity tend to describe their command verbs as being in the 7bit ASCII set (which has relatively straightforward case folding rules) and punt the problem of case folding to the server (which essentially means that you either support case sensitivity or you assume some kind of network codepage).