From 6d8a759c751a67d7d92a5b11a775190bd800468c 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. --- common/utf8.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/utf8.cpp b/common/utf8.cpp index 1895955806..2d23e78146 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(...) { @@ -233,4 +233,4 @@ UTF8& UTF8::operator+=( unsigned w_ch ) } return (UTF8&) *this; -} \ No newline at end of file +}