0

When using the following code to call OutputDebugString on a Windows 7 box I only see "????" in the print column of DebugView. I think this may be an encoding related issue but not sure is anyone has seen this before. Here is the code I am using to call OutputDebugString.

void dbgprint(char *format, ...)
{
    static  DWORD pid=0;
    va_list vl;
    char    dbgbuf1[2048],
            dbgbuf2[2048];

    // Prepend the process ID to the message
    if ( 0 == pid )
    {
        pid = GetCurrentProcessId();
    }

    EnterCriticalSection(&gDebugCritSec);
    va_start(vl, format);
    wvsprintf(dbgbuf1, format, vl);
    wsprintf(dbgbuf2, "%lu: %s\r\n", pid, dbgbuf1);
    va_end(vl);

    OutputDebugString(dbgbuf2);
    LeaveCriticalSection(&gDebugCritSec);
}

enter image description here

Thanks in advance for any insight into this issue.

Doug
  • 5,268
  • 24
  • 31

1 Answers1

1

As you say, it's probably an encoding issue. Just test it with:

OutputDebugStringA("This is a non-unicode test");

Two more things,

  1. you do not have to prefix the PID, because OutputDebugString sends that along with the message already.
  2. Check out DebugView++ at https://github.com/djeedjay/DebugViewPP
Jan Wilmans
  • 665
  • 6
  • 10