Skip to content

Re-enable compilation using GCC version 4.9 #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/util/unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ Author: Daniel Kroening, [email protected]

\*******************************************************************/

#ifndef __GNUC__
# define HAVE_CODECVT
#elif(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 50000
# define HAVE_CODECVT
#endif

#include <cstring>
#include <locale>
#include <codecvt>
#ifdef HAVE_CODECVT
# include <codecvt>
#endif
#include <iomanip>
#include <sstream>

Expand Down Expand Up @@ -277,8 +285,12 @@ Function: utf8_to_utf16_big_endian

std::wstring utf8_to_utf16_big_endian(const std::string& in)
{
#ifdef HAVE_CODECVT
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
return converter.from_bytes(in);
#else
throw "compiled without UTF16 support";
#endif
}

/*******************************************************************\
Expand All @@ -295,6 +307,7 @@ Function: utf8_to_utf16_little_endian

std::wstring utf8_to_utf16_little_endian(const std::string& in)
{
#ifdef HAVE_CODECVT
const std::codecvt_mode mode=std::codecvt_mode::little_endian;

// default largest value codecvt_utf8_utf16 reads without error is 0x10ffff
Expand All @@ -304,6 +317,9 @@ std::wstring utf8_to_utf16_little_endian(const std::string& in)
typedef std::codecvt_utf8_utf16<wchar_t, maxcode, mode> codecvt_utf8_utf16t;
std::wstring_convert<codecvt_utf8_utf16t> converter;
return converter.from_bytes(in);
#else
throw "compiled without UTF16 support";
#endif
}

/*******************************************************************\
Expand Down