输出英文正常,但输出中文全是乱码,我记得好象有哪个API可以转换,或者有其他方法,向各位请教.

解决方案 »

  1.   

    你是输出到哪里?文本文件?如果是文本文件的话,需要在正式内容前加上0xFF 0xFE 这两个标志字节
      

  2.   

    好像没有这样的API,我以前用的是一个老外写的一个类
      

  3.   

    Using Generic-Text Mappings
    Microsoft Specific —>To simplify code development for various international ets, the Microsoft run-time library provides Microsoft-specific “generic-text” mappings for many data types, routines, and other objects. These mappings are defined in TCHAR.H. You can use these name mappings to write generic code that can be compiled for any of the three kinds of character sets: ASCII (SBCS), MBCS, or Unicode, depending on a manifest constant you define using a #define statement. Generic-text mappings are Microsoft extensions that are not ANSI compatible.Preprocessor Directives for Generic-Text Mappings#define Compiled Version Example  
    _UNICODE Unicode (wide-character) _tcsrev maps to _wcsrev 
    _MBCS Multibyte-character _tcsrev maps to _mbsrev 
    None (the default: neither _UNICODE nor _MBCS defined) SBCS (ASCII) _tcsrev maps to strrev 
    For example, the generic-text function _tcsrev, defined in TCHAR.H, maps to mbsrev if MBCS has been defined in your program, or to _wcsrev if _UNICODE has been defined. Otherwise _tcsrev maps to strrev. The generic-text data type _TCHAR, also defined in TCHAR.H, maps to type char if _MBCS is defined, to type wchar_t if _UNICODE is defined, and to type char if neither constant is defined. Other data type mappings are provided in TCHAR.H for programming convenience, but _TCHAR is the type that is most useful. Generic-Text Data Type MappingsGeneric-Text Data Type Name SBCS (_UNICODE, _MBCS Not Defined) 
    _MBCS Defined 
    _UNICODE Defined 
    _TCHAR char char wchar_t 
    _TINT int int wint_t 
    _TSCHAR signed char signed char wchar_t 
    _TUCHAR unsigned char unsigned char wchar_t 
    _TXCHAR char unsigned char wchar_t 
    _T or _TEXT No effect (removed by preprocessor) No effect (removed by preprocessor) L (converts following character or string to its Unicode counterpart) 
    For a complete list of generic-text mappings of routines, variables, and other objects, see Appendix B, Generic-Text Mappings.The following code fragments illustrate the use of _TCHAR and _tcsrev for mapping to the MBCS, Unicode, and SBCS models._TCHAR *RetVal, *szString;
    RetVal = _tcsrev(szString);If MBCS has been defined, the preprocessor maps the preceding fragment to the following code:char *RetVal, *szString;
    RetVal = _mbsrev(szString);If _UNICODE has been defined, the preprocessor maps the same fragment to the following code:wchar_t *RetVal, *szString;
    RetVal = _wcsrev(szString);If neither _MBCS nor _UNICODE has been defined, the preprocessor maps the fragment to single-byte ASCII code, as follows:char *RetVal, *szString;
    RetVal = strrev(szString);Thus you can write, maintain, and compile a single source code file to run with routines that are specific to any of the three kinds of character sets. See Also   Generic-text mappings, Data type mappings, Constants and global variable mappings, Routine mappings, A sample generic-text propgramEND Microsoft Specific
      

  4.   

    See more details via MSDN
      

  5.   


    如果你程序沒有定義unicode話用這個先轉換成ansi的輸出
    char a[256];
    CString csFloatVar;
    WideCharToMultiByte( CP_ACP, 0,(LPCWSTR)csFloatVar, -1,
            a, 256, NULL, NULL );
    SetWindowText(a)
      

  6.   

    用这个函数WideCharToMultiByte()把宽字符转换为ansi.