From: LRN <lr...@gm...> - 2012-01-11 20:20:29
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11.01.2012 22:21, Gisle Vanem wrote: > "LRN" <lr...@gm...> wrote: > >> Attach the program, it's difficult to tell without seeing the >> minimal program (or, at least, the pieces of code where you call >> GetAdaptersAddresses() and print the results). > > Attached is a minimal program; checked it with MingW, MSVC (cl 16) > and Watcom. Only the latter prints national characters correctly. > From ip_info.exe (MingW): > > Information from GetAdaptersAddresses(): Adapter name: > {37FC13D9-2F52-47CA-AB64-32B2B434C749} Description: NETGEAR WG111v2 > 54Mbps Wireless USB 2.0 Adapter #2 Friendly name: TrÕdl°s > nettverkstilkobling Adapter name: > {8D3A23A7-9C6C-408B-A23B-6736F9E56510} Description: Realtek PCIe > GBE Family Controller Friendly name: BredbÕnd forbindelse Adapter > name: {75451EE7-5145-471A-BAF5-124BE8439D10} Description: WAN > (PPP/SLIP) Interface Friendly name: Strong VPN etc. > > Can anybody check the attached program? Build instructions inside. > You're trying to output strings encoded in UTF-16 to a text console that has your system's default ANSI codepage set up. If you try and open a file for writing in binary mode (at least i've tried that in binary mode, not sure whether it would work in text mode or not; you might also be able to re-open stdout in binary mode, i haven't tried that either) and write strings into it instead of stdout, they will come out in the right encoding (UTF-16; though it would advise you to NOT to mix UTF-16 and system codepage the way you do, either stick to UTF-16, or to system codepage, or to UTF-8). Speaking of which, you can use SetConsoleCP() to set console output codepage to something better, like UTF-8, and write strings encoded that way, and they will show up nicely. SetConsoleCP() does not seem to be able to set UTF-16 encoding, which means that you can't write wide strings into console directly, you need to convert them to UTF-8 (or whatever you're going to use). I'm not sure why Watcom-compiled code works. Maybe it has its own C runtime that handles this problem? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPDe8BAAoJEOs4Jb6SI2Cwy3kH/0uWwAb7W+knZqPschRK4rpq yTwx43kDhZ1k7NzMWKuFkTvJoIn/oHPI7kLRbI8ey6pG6tM35nlAhcMdnPDKif12 mHyKGqryOO2GBBHnqzy2oy4wKksXT03jIWxwg+2aQXywDGSosCScNIkfUZz13JsX FmAzio3Aek5TvuH2c4kyAW1R6c67nexWdcYuqGsLJCkXGcWpr0l9zra1ZmxHiTES KhiVzED3MZVUWQR4FNka1F6MCJVLYDgejkhVz+ulreNqgWh8g9Y2yYI/HWxp1S03 duSpwvjiz3Yh5wvr3F/psp06a6Hhe0z1ZGUWvQr71+1h++fUN+LcMjnwejEy8xg= =hhyG -----END PGP SIGNATURE----- |