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()); +}