codecvt::out

将内部 CharType按顺序为外部 Bytes.序列。

result out(
    StateType& _State,
    const CharType* _First1, 
    const CharType* _Last1,
    const CharType*& _Next1,
    Byte* _First2, 
    Byte* _Last2, 
    Byte*& _Next2
) const;

参数

  • _State
    维护得之间的转换状态调用成员函数。

  • _First1
    要转换的开头的指针。

  • _Last1
    要转换的序列的结尾的指针。

  • _Next1
    对指向第一个没有重 CharType 在最后一 CharType 后平移。

  • _First2
    对强制转换序列的开头的指针。

  • _Last2
    对强制转换序列的末尾的指针。

  • _Next2
    对指向第一个没有重 Byte 在最后一个转换的 Byte之后。

返回值

成员函数返回 do_out(_State、_First1、_Last1、_Next1、_First2、_Last2,_Next2)。

备注

有关更多信息,请参见 codecvt::do_out

示例

// codecvt_out.cpp
// compile with: /EHsc
#define _INTL
#include <locale>
#include <iostream>
#include <wchar.h>
using namespace std;
#define LEN 90
int main( )   
{
   char pszExt[LEN+1];
   wchar_t *pwszInt = L"This is the wchar_t string to be converted.";
   memset( &pszExt[0], 0, ( sizeof( char ) )*( LEN+1 ) );
   char* pszNext;
   const wchar_t* pwszNext;
   mbstate_t state;
   locale loc("C");//English_Britain");//German_Germany
   int res = use_facet<codecvt<wchar_t, char, mbstate_t> >
      ( loc ).out( state,
      pwszInt, &pwszInt[wcslen( pwszInt )], pwszNext ,
      pszExt, &pszExt[wcslen( pwszInt )], pszNext );
   pszExt[wcslen( pwszInt )] = 0;
   cout << ( ( res!=codecvt_base::error ) ? "It worked: " : "It didn't work: " )
   << "The converted string is:\n ["
   << &pszExt[0]
   << "]" << endl;
}
  

要求

标头: <locale>

命名空间: std

请参见

参考

codecvt Class