Skip to content

Commit

Permalink
Switch libupnp to unicode as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Paxxi committed Mar 1, 2017
1 parent 7070d1c commit f9f046e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/libUPnP/Neptune/Source/System/Win32/NptWin32Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

#include "NptConfig.h"
#include "NptConsole.h"
#include "NptDebug.h"

/*----------------------------------------------------------------------
| NPT_Console::Output
+---------------------------------------------------------------------*/
void
NPT_Console::Output(const char* message)
{
OutputDebugString(message);
NPT_DebugOutput(message);
printf("%s", message);
}

20 changes: 12 additions & 8 deletions lib/libUPnP/Neptune/Source/System/Win32/NptWin32Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,30 @@
| includes
+---------------------------------------------------------------------*/
#include <stdio.h>
#if defined(_XBOX)
#include <xtl.h>
#else
#include <windows.h>
#endif

#include "NptConfig.h"
#include "NptDefs.h"
#include "NptTypes.h"
#include "NptDebug.h"
#include <memory>

/*----------------------------------------------------------------------
| NPT_DebugOutput
+---------------------------------------------------------------------*/
void
NPT_DebugOutput(const char* message)
{
#if !defined(_WIN32_WCE)
OutputDebugString(message);
#endif
printf("%s", message);
int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, message, -1, nullptr, 0);
if (result == 0)
return;

auto newStr = std::make_unique<wchar_t[]>(result + 1);
result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, message, result, newStr.get(), result);

if (result == 0)
return;

OutputDebugString(newStr.get());
}

Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ NPT_Win32SerialPort::Open(unsigned int speed,
NPT_SerialPortFlowControl flow_control,
NPT_SerialPortParity parity)
{
return NPT_FAILURE; // We don't need serial port suppurt
#if 0
// check if we're already open
if (!m_HandleReference.IsNull()) {
return NPT_ERROR_SERIAL_PORT_ALREADY_OPEN;
Expand Down Expand Up @@ -278,6 +280,7 @@ NPT_Win32SerialPort::Open(unsigned int speed,
m_HandleReference = new NPT_Win32HandleWrapper(handle);

return NPT_SUCCESS;
#endif
}

/*----------------------------------------------------------------------
Expand Down

0 comments on commit f9f046e

Please sign in to comment.