std::string<->std::wstring convert

 std::wstring FromCodePage( unsigned int codpage , const std::string& utf8string )
 {
  
  int widesize = ::MultiByteToWideChar( codpage, 0, utf8string.c_str(), -1, NULL, 0);
  if (widesize == ERROR_NO_UNICODE_TRANSLATION)
  {
   printf("Invalid UTF-8 sequence.");
  }
  if (widesize == 0)
  {
   printf("Error in conversion.");
  }

  std::vector<wchar_t> resultstring(widesize+1);

  int convresult = ::MultiByteToWideChar(codpage, 0, utf8string.c_str(), -1, &resultstring[0], widesize+1);

  if (convresult != widesize)
  {
   printf("Utf8 - Utf16 Conversion error!");
  }

  return std::wstring(&resultstring[0]);
 }

 std::wstring FromUtf8(const std::string& utf8string)
 {
  return FromCodePage( CP_UTF8, utf8string );
 }

 std::wstring FromAsc( const std::string& ascstring  )
 {
  return  FromCodePage( CP_ACP, ascstring ) ;
 }
 

 std::string ToCodePage(unsigned int codepage, const std::wstring& widestring)
 {
  int out_size = ::WideCharToMultiByte( codepage, 0, widestring.c_str(), -1, NULL, 0, NULL, NULL );
  if (out_size == 0)
  {
   throw GCN_EXCEPTION("Error in conversion.");
  }
  
  std::vector<char> resultstring(out_size);
  
  int convresult = ::WideCharToMultiByte(codepage, 0, widestring.c_str(), -1, &resultstring[0], out_size, NULL, NULL);
  
  if (convresult != out_size)
  {
   throw GCN_EXCEPTION("Utf16 - Codepage Conversion error!");
  }
  
  return std::string(&resultstring[0]);
 }
 
 
 std::string ToUtf8(const std::wstring& widestring)
 {  
  return ToCodePage( CP_UTF8, widestring );
 }


 std::string ToAsc(const std::wstring& widestring)
 {  
  return ToCodePage( CP_ACP, widestring );
 }