From 43987cc50c00ea1062952c27801cbd7914b212d0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 18 Oct 2018 06:11:41 -0700 Subject: [PATCH] UTF8: Fix MSVC builds MSVC does not support variable length arrays. Substitute a std::vector instead. (cherry picked from commit 6d8a759c751a67d7d92a5b11a775190bd800468c) --- common/utf8.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/utf8.cpp b/common/utf8.cpp index f3d7d118c6..80357ffb29 100644 --- a/common/utf8.cpp +++ b/common/utf8.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* THROW_IO_ERROR needs this, but it includes this file, so until some factoring of THROW_IO_ERROR into a separate header, defer and use the asserts. @@ -203,10 +204,9 @@ UTF8::UTF8( const wchar_t* txt ) { try { - size_t len = wcslen( txt ) * 4 + 1; - char temp[len]; - wxConvUTF8.WC2MB( temp, txt, len ); - m_s.assign( temp ); + std::vector< char > temp( wcslen( txt ) * 4 + 1 ); + wxConvUTF8.WC2MB( temp.data(), txt, temp.size() ); + m_s.assign( temp.data() ); } catch(...) {