I am trying to read a UTF-8 text file in Visual C++ 2010 using only the standard library and not Boost or Windows APIs. I define the locale as:
std::locale utf8_locale(std::locale(), new std::codecvt_utf8<wchar_t>);
but this results in the following compiler error:
error C2661: 'std::locale::facet::operator new' : no overloaded function takes 3 arguments
error C2664: 'std::locale::locale(const char *,std::locale::category)' : cannot convert parameter 1 from 'std::locale' to 'const char *'
The error is occures in debug mode when the code is used in the file that micrsoft Visual c++ provided below macro is placed.
to get rid of this error the
#define new DEBUG_NEWshould be commented out or the code should be implemented in another file which does not have the above macro.This bug for Visual c++ 2010 is mentioned here http://connect.microsoft.com/VisualStudio/feedback/details/683483/mfc-c-fails-to-compile-use-of-codecvt-utf8-in-debug-configuration