aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr/Exception.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-09-10 20:51:02 +0200
committerPierre Ossman <ossman@cendio.se>2024-11-06 21:00:18 +0100
commit067d0e89bf344609ec202f895252411c8fcaec1c (patch)
treeee215e6c565b054579950bf2604d6718306e72b3 /common/rdr/Exception.cxx
parente6d4d3cbb4242d536474f4e8e2262bc5886200db (diff)
downloadtigervnc-067d0e89bf344609ec202f895252411c8fcaec1c.tar.gz
tigervnc-067d0e89bf344609ec202f895252411c8fcaec1c.zip
Get Unicode Windows error strings
These seem to always be in ASCII and English, unfortunately, but let's at least use the API the could give use something more useful.
Diffstat (limited to 'common/rdr/Exception.cxx')
-rw-r--r--common/rdr/Exception.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx
index 6a03fa54..4c99d977 100644
--- a/common/rdr/Exception.cxx
+++ b/common/rdr/Exception.cxx
@@ -1,6 +1,7 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright (C) 2004 Red Hat Inc.
* Copyright (C) 2010 TigerVNC Team
+ * Copyright 2014-2024 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -80,7 +81,15 @@ PosixException::PosixException(const char* s, int err_)
: Exception("%s", s), err(err_)
{
strncat(str_, ": ", len-1-strlen(str_));
+#ifdef _WIN32
+ wchar_t *currStr = new wchar_t[len-strlen(str_)];
+ wcsncpy(currStr, _wcserror(err), len-1-strlen(str_));
+ WideCharToMultiByte(CP_UTF8, 0, currStr, -1, str_+strlen(str_),
+ len-1-strlen(str_), nullptr, nullptr);
+ delete [] currStr;
+#else
strncat(str_, strerror(err), len-1-strlen(str_));
+#endif
strncat(str_, " (", len-1-strlen(str_));
char buf[20];
sprintf(buf,"%d",err);