mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:06:34 +00:00
[HELP]: Fix console output for languages using non-latin characters. Patch by Vort.
CORE-7409 #resolve #comment Fixed, thanks! svn path=/trunk/; revision=66507
This commit is contained in:
parent
99126ff14b
commit
0107779ca0
1 changed files with 11 additions and 40 deletions
|
@ -21,50 +21,21 @@
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
BOOL IsConsoleHandle(HANDLE hHandle)
|
|
||||||
{
|
|
||||||
DWORD dwMode;
|
|
||||||
|
|
||||||
/* Check whether the handle may be that of a console... */
|
|
||||||
if ((GetFileType(hHandle) & ~FILE_TYPE_REMOTE) != FILE_TYPE_CHAR)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* It may be. Perform another test... The idea comes from the
|
|
||||||
* MSDN description of the WriteConsole API:
|
|
||||||
*
|
|
||||||
* "WriteConsole fails if it is used with a standard handle
|
|
||||||
* that is redirected to a file. If an application processes
|
|
||||||
* multilingual output that can be redirected, determine whether
|
|
||||||
* the output handle is a console handle (one method is to call
|
|
||||||
* the GetConsoleMode function and check whether it succeeds).
|
|
||||||
* If the handle is a console handle, call WriteConsole. If the
|
|
||||||
* handle is not a console handle, the output is redirected and
|
|
||||||
* you should call WriteFile to perform the I/O."
|
|
||||||
*/
|
|
||||||
return GetConsoleMode(hHandle, &dwMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID PrintResourceString(INT resID, ...)
|
VOID PrintResourceString(INT resID, ...)
|
||||||
{
|
{
|
||||||
HANDLE OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
WCHAR bufSrc[RC_STRING_MAX_SIZE];
|
||||||
WCHAR tmpBuffer[RC_STRING_MAX_SIZE];
|
WCHAR bufFormatted[RC_STRING_MAX_SIZE];
|
||||||
va_list arg_ptr;
|
CHAR bufFormattedOem[RC_STRING_MAX_SIZE];
|
||||||
|
|
||||||
va_start(arg_ptr, resID);
|
va_list args;
|
||||||
LoadStringW(GetModuleHandleW(NULL), resID, tmpBuffer, RC_STRING_MAX_SIZE);
|
va_start(args, resID);
|
||||||
|
|
||||||
// FIXME: Optimize by using Win32 console functions.
|
LoadStringW(GetModuleHandleW(NULL), resID, bufSrc, RC_STRING_MAX_SIZE);
|
||||||
if (IsConsoleHandle(OutputHandle))
|
vswprintf(bufFormatted, bufSrc, args);
|
||||||
{
|
CharToOemW(bufFormatted, bufFormattedOem);
|
||||||
vfwprintf(stdout, tmpBuffer, arg_ptr);
|
fputs(bufFormattedOem, stdout);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vwprintf(tmpBuffer, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(arg_ptr);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IsInternalCommand(LPCWSTR Cmd)
|
BOOL IsInternalCommand(LPCWSTR Cmd)
|
||||||
|
@ -75,7 +46,7 @@ BOOL IsInternalCommand(LPCWSTR Cmd)
|
||||||
/* Invalid command */
|
/* Invalid command */
|
||||||
if (!Cmd) return FALSE;
|
if (!Cmd) return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(InternalCommands)/sizeof(InternalCommands[0]); ++i)
|
for (i = 0; i < ARRAYSIZE(InternalCommands); ++i)
|
||||||
{
|
{
|
||||||
res = _wcsicmp(InternalCommands[i], Cmd);
|
res = _wcsicmp(InternalCommands[i], Cmd);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue