string与utf8编码有关问题

string与utf8编码问题
我C++调用一个curl插件访问网页获取utf8格式的数据流,
c#接收代码如下:

private Int32 OnWriteData(Byte[] buf, Int32 size, Int32 nmemb, Object extraData)
 {
      rc += System.Text.Encoding.GetEncoding(this.encoding).GetString(buf);
      return size * nmemb;
}

C++接收代码如下:

size_t WriteCallback(void *ptr, size_t size, size_t nmemb, void *data) 
{  
string *buff = (string*) data;  
buff->append((char *) ptr, size * nmemb);  
return size* nmemb;  
}

C++目前接收输出后是乱码,不识别汉字,怎么才能以UTF8格式或GB18030格式接收呀?
谢谢指教.
------解决方案--------------------
乱码是因为你终端配置的编码和文本编码不同造成的,调整你的终端编码为utf8就可以看见utf8编码的文本了
------解决方案--------------------
帮顶 顺便mark一下
------解决方案--------------------
MultiByteToWideChar
The MultiByteToWideChar function maps a character string to a wide-character (Unicode) string. The character string mapped by this function is not necessarily from a multibyte character set. 

int MultiByteToWideChar(
  UINT CodePage,         // code page
  DWORD dwFlags,         // character-type options
  LPCSTR lpMultiByteStr, // address of string to map
  int cchMultiByte,      // number of bytes in string
  LPWSTR lpWideCharStr,  // address of wide-character buffer
  int cchWideChar        // size of buffer
);
 
Parameters
CodePage 
Specifies the code page to be used to perform the conversion. This parameter can be given the value of any code page that is installed or available in the system. You can also specify one of the following values: Value Meaning 
CP_ACP ANSI code page 
CP_MACCP Macintosh code page 
CP_OEMCP OEM code page 
CP_SYMBOL Symbol code page (42) 
CP_THREAD_ACP The current thread's ANSI code page 
CP_UTF7 Translate using UTF-7 
CP_UTF8 Translate using UTF-8 


dwFlags 
A set of bit flags that indicate whether to translate to precomposed or composite wide characters (if a composite form exists), whether to use glyph characters in place of control characters, and how to deal with invalid characters. You can specify a combination of the following flag constants: Value Meaning 
MB_PRECOMPOSED Always use precomposed characters — that is, characters in which a base character and a nonspacing character have a single character value. This is the default translation option. Cannot be used with MB_COMPOSITE. 
MB_COMPOSITE Always use composite characters — that is, characters in which a base character and a nonspacing character have different character values. Cannot be used with MB_PRECOMPOSED. 
MB_ERR_INVALID_CHARS If the function encounters an invalid input character, it fails and GetLastError returns ERROR_NO_UNICODE_TRANSLATION.  
MB_USEGLYPHCHARS Use glyph characters instead of control characters. 


A composite character consists of a base character and a nonspacing character, each having different character values. A precomposed character has a single character value for a base/non-spacing character combination. In the character è, the e is the base character and the accent grave mark is the nonspacing character. 

The function's default behavior is to translate to the precomposed form. If a precomposed form does not exist, the function attempts to translate to a composite form. 

The flags MB_PRECOMPOSED and MB_COMPOSITE are mutually exclusive. The MB_USEGLYPHCHARS flag and the MB_ERR_INVALID_CHARS can be set regardless of the state of the other flags.