From: Tietew Date: 2008-06-24T12:14:06+09:00 Subject: [ruby-dev:35213] Re: Win32 Unicode console output On Tue, 24 Jun 2008 00:20:12 +0900 In article <20080624001939.BD20.USA@garbagecollect.jp> [[ruby-dev:35209] Re: Win32 Unicode console output] "U.Nakamura" wrote: > | GetConsole を呼んで、コンソールか調べてから、WriteConsoleW を呼べばいいっぽいですね。 > > GetConsole()でわかるのかなあ... > なおwin32/win32.cにはis_console()というのがあるのでその辺は大 MSVCR90 によると、GetConsoleMode を呼べばいいみたいです。 モード値は無視して、返値が true ならコンソール、false (エラー) ならそれ 以外。 これなら SOCKET が渡されてもあんしんじゃないでしょうか。 ---- /* * Note that in case the handle belongs to Console, write file will * generate garbage output. For user to print these characters * correctly, we will need to print ANSI. * * Also note that in case of printing to Console, we still have to * convert the characters to console codepage. */ if (_isatty(fh) && (_osfile(fh) & FTEXT)) { DWORD dwMode; _ptiddata ptd = _getptd(); isCLocale = (ptd->ptlocinfo->lc_handle[LC_CTYPE] == _CLOCALEHANDLE); toConsole = GetConsoleMode((HANDLE)_osfhnd(fh), &dwMode); } -- Tietew Blog: http://www.tietew.jp/ PGP: 26CB 71BB B595 09C4 0153 81C4 773C 963A D51B 8CAA