summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-09 09:23:44 -0400
committerPietro Gagliardi <[email protected]>2015-04-09 09:24:08 -0400
commit1f18d88f565844436fb4487b596175ba48138c05 (patch)
tree39aaac35a85e48e572f7f4d7b3798fcf7289c116
parent723f2af8c621525848a234d88d98b5107cf0d683 (diff)
Split toUTF16() into a new file; other Windows text functions will also be there.
-rw-r--r--new/text_windows.c18
-rw-r--r--new/uipriv_windows.h2
-rw-r--r--new/util_windows.c16
3 files changed, 19 insertions, 17 deletions
diff --git a/new/text_windows.c b/new/text_windows.c
new file mode 100644
index 0000000..e483a95
--- /dev/null
+++ b/new/text_windows.c
@@ -0,0 +1,18 @@
+// 9 april 2015
+#include "uipriv_windows.h"
+
+#define MBTWC(str, wstr, bufsiz) MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, bufsiz)
+
+WCHAR *toUTF16(const char *str)
+{
+ WCHAR *wstr;
+ int n;
+
+ n = MBTWC(str, NULL, 0);
+ if (n == 0)
+ logLastError("error figuring out number of characters to convert to in toUTF16()");
+ wstr = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]");
+ if (MBTWC(str, wstr, n) != n)
+ logLastError("error converting from UTF-8 to UTF-16 in toUTF16()");
+ return wstr;
+}
diff --git a/new/uipriv_windows.h b/new/uipriv_windows.h
index 5383b54..99c742b 100644
--- a/new/uipriv_windows.h
+++ b/new/uipriv_windows.h
@@ -47,7 +47,7 @@ extern int nCmdShow;
extern HFONT hMessageFont;
extern HWND initialParent;
-// util_windows.c
+// text_windows.c
extern WCHAR *toUTF16(const char *);
// container_windows.c
diff --git a/new/util_windows.c b/new/util_windows.c
index 5034dae..4959a70 100644
--- a/new/util_windows.c
+++ b/new/util_windows.c
@@ -1,22 +1,6 @@
// 6 april 2015
#include "uipriv_windows.h"
-#define MBTWC(str, wstr, bufsiz) MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, bufsiz)
-
-WCHAR *toUTF16(const char *str)
-{
- WCHAR *wstr;
- int n;
-
- n = MBTWC(str, NULL, 0);
- if (n == 0)
- logLastError("error figuring out number of characters to convert to in toUTF16()");
- wstr = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]");
- if (MBTWC(str, wstr, n) != n)
- logLastError("error converting from UTF-8 to UTF-16 in toUTF16()");
- return wstr;
-}
-
intmax_t uiWindowsWindowTextWidth(HWND hwnd)
{
int len;