From 473e0c9b693c375178e77dcbf85d1b4c2c87f2d0 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 17 May 2016 12:35:44 -0400 Subject: [PATCH] Actually first let's do event handling. This adds a ftoutf16() function we can use here. --- windows/uipriv_windows.hpp | 1 + windows/utf16.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/windows/uipriv_windows.hpp b/windows/uipriv_windows.hpp index e207f1bc..555c687b 100644 --- a/windows/uipriv_windows.hpp +++ b/windows/uipriv_windows.hpp @@ -37,6 +37,7 @@ extern WCHAR *strf(const WCHAR *format, ...); extern WCHAR *vstrf(const WCHAR *format, va_list ap); extern char *LFtoCRLF(const char *lfonly); extern void CRLFtoLF(const char *s); +extern WCHAR *ftoutf16(double d); // debug.cpp // see http://stackoverflow.com/questions/14421656/is-there-widely-available-wide-character-variant-of-file diff --git a/windows/utf16.cpp b/windows/utf16.cpp index 374cec9b..07fd4363 100644 --- a/windows/utf16.cpp +++ b/windows/utf16.cpp @@ -128,3 +128,15 @@ void CRLFtoLF(char *s) while (t != s) *t++ = '\0'; } + +// std::to_string() always uses %f; we want %g +// fortunately std::iostream seems to use %g by default so +WCHAR *ftoutf16(double d) +{ + std::wostringstream ss; + std::wstring s; + + ss << d; + s = ss.str(); // to be safe + return utf16dup(s.c_str()); +}