本文整理汇总了C++中CNativeW::_GetMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ CNativeW::_GetMemory方法的具体用法?C++ CNativeW::_GetMemory怎么用?C++ CNativeW::_GetMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNativeW
的用法示例。
在下文中一共展示了CNativeW::_GetMemory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadLineW
wstring CTextInputStream::ReadLineW()
{
//$$ 非効率だけど今のところは許して。。
CNativeW line;
line.AllocStringBuffer(60);
for (;;) {
int c=getc(GetFp());
if(c==EOF)break; //EOFで終了
if(c=='\r'){ c=getc(GetFp()); if(c!='\n')ungetc(c,GetFp()); break; } //"\r" または "\r\n" で終了
if(c=='\n')break; //"\n" で終了
if( line._GetMemory()->capacity() < line._GetMemory()->GetRawLength() + 10 ){
line._GetMemory()->AllocBuffer( line._GetMemory()->GetRawLength() * 2 );
}
line._GetMemory()->AppendRawData(&c,sizeof(char));
}
//UTF-8 → UNICODE
if(m_bIsUtf8){
CUtf8::UTF8ToUnicode(*(line._GetMemory()), &line);
}
//Shift_JIS → UNICODE
else{
CShiftJis::SJISToUnicode(*(line._GetMemory()), &line);
}
return wstring().assign( line.GetStringPtr(), line.GetStringLength() ); // EOL まで NULL 文字も含める
}
示例2: UnicodeToHex
// 文字コード表示用 UNICODE → Hex 変換 2008/6/9 Uchi
EConvertResult CEuc::UnicodeToHex(const wchar_t* cSrc, const int iSLen, TCHAR* pDst, const CommonSetting_Statusbar* psStatusbar)
{
CNativeW cCharBuffer;
EConvertResult res;
int i;
TCHAR* pd;
unsigned char* ps;
bool bbinary=false;
// 2008/6/21 Uchi
if (psStatusbar->m_bDispUniInEuc) {
// Unicodeで表示
return CCodeBase::UnicodeToHex(cSrc, iSLen, pDst, psStatusbar);
}
// 1文字データバッファ
cCharBuffer.SetString(cSrc, 1);
if( IsBinaryOnSurrogate(cSrc[0]) ){
bbinary = true;
}
// EUC-JP 変換
res = UnicodeToEUC(cCharBuffer, cCharBuffer._GetMemory());
if (res != RESULT_COMPLETE) {
return res;
}
// Hex変換
ps = reinterpret_cast<unsigned char*>( cCharBuffer._GetMemory()->GetRawPtr() );
pd = pDst;
if( bbinary == false ){
for (i = cCharBuffer._GetMemory()->GetRawLength(); i >0; i--, ps ++, pd += 2) {
auto_sprintf( pd, _T("%02X"), *ps);
}
}else{
auto_sprintf( pd, _T("?%02X"), *ps );
}
return RESULT_COMPLETE;
}
示例3: UnicodeToHex
// 文字コード表示用 UNICODE → Hex 変換 2008/6/21 Uchi
EConvertResult CUtf8::_UnicodeToHex(const wchar_t* cSrc, const int iSLen, TCHAR* pDst, const CommonSetting_Statusbar* psStatusbar, const bool bCESUMode)
{
CNativeW cBuff;
EConvertResult res;
int i;
TCHAR* pd;
unsigned char* ps;
bool bbinary=false;
if (psStatusbar->m_bDispUtf8Codepoint) {
// Unicodeで表示
return CCodeBase::UnicodeToHex(cSrc, iSLen, pDst, psStatusbar);
}
cBuff.AllocStringBuffer(4);
// 1文字データバッファ
if (IsUTF16High(cSrc[0]) && iSLen >= 2 && IsUTF16Low(cSrc[1])) {
cBuff._GetMemory()->SetRawDataHoldBuffer(cSrc, 4);
}
else {
cBuff._GetMemory()->SetRawDataHoldBuffer(cSrc, 2);
if( IsBinaryOnSurrogate(cSrc[0]) ){
bbinary = true;
}
}
// UTF-8/CESU-8 変換
if (bCESUMode != true) {
res = UnicodeToUTF8(cBuff, cBuff._GetMemory());
}
else {
res = UnicodeToCESU8(cBuff, cBuff._GetMemory());
}
if (res != RESULT_COMPLETE) {
return res;
}
// Hex変換
ps = reinterpret_cast<unsigned char*>( cBuff._GetMemory()->GetRawPtr() );
pd = pDst;
if( bbinary == false ){
for (i = cBuff._GetMemory()->GetRawLength(); i >0; i--, ps ++, pd += 2) {
auto_sprintf( pd, _T("%02X"), *ps);
}
}else{
auto_sprintf( pd, _T("?%02X"), *ps );
}
return RESULT_COMPLETE;
}
示例4: WriteFile_From_CDocLineMgr
/*! バッファ内容をファイルに書き出す (テスト用)
@note Windows用にコーディングしてある
@date 2003.07.26 ryoji BOM引数追加
*/
EConvertResult CWriteManager::WriteFile_From_CDocLineMgr(
const CDocLineMgr& pcDocLineMgr, //!< [in]
const SSaveInfo& sSaveInfo //!< [in]
)
{
EConvertResult nRetVal = RESULT_COMPLETE;
std::auto_ptr<CCodeBase> pcCodeBase( CCodeFactory::CreateCodeBase(sSaveInfo.eCharCode,0) );
{
// 変換テスト
CNativeW buffer = L"abcde";
CMemory tmp;
EConvertResult e = pcCodeBase->UnicodeToCode( buffer, &tmp );
if(e==RESULT_FAILURE){
nRetVal=RESULT_FAILURE;
ErrorMessage(
CEditWnd::getInstance()->GetHwnd(),
LS(STR_FILESAVE_CONVERT_ERROR),
sSaveInfo.cFilePath.c_str()
);
return nRetVal;
}
}
try
{
//ファイルオープン
CBinaryOutputStream out(sSaveInfo.cFilePath,true);
//各行出力
int nLineNumber = 0;
const CDocLine* pcDocLine = pcDocLineMgr.GetDocLineTop();
// 1行目
{
++nLineNumber;
CMemory cmemOutputBuffer;
{
CNativeW cstrSrc;
CMemory cstrBomCheck;
pcCodeBase->GetBom( &cstrBomCheck );
if( sSaveInfo.bBomExist && 0 < cstrBomCheck.GetRawLength() ){
// 1行目にはBOMを付加する。エンコーダでbomがある場合のみ付加する。
CUnicode().GetBom( cstrSrc._GetMemory() );
}
if( pcDocLine ){
cstrSrc.AppendNativeData( pcDocLine->_GetDocLineDataWithEOL() );
}
EConvertResult e = pcCodeBase->UnicodeToCode( cstrSrc, &cmemOutputBuffer );
if(e==RESULT_LOSESOME){
nRetVal=RESULT_LOSESOME;
}
if(e==RESULT_FAILURE){
nRetVal=RESULT_FAILURE;
ErrorMessage(
CEditWnd::getInstance()->GetHwnd(),
LS(STR_FILESAVE_CONVERT_ERROR),
sSaveInfo.cFilePath.c_str()
);
throw CError_FileWrite();
}
}
out.Write(cmemOutputBuffer.GetRawPtr(), cmemOutputBuffer.GetRawLength());
if( pcDocLine ){
pcDocLine = pcDocLine->GetNextLine();
}
}
CMemory cmemOutputBuffer;
while( pcDocLine ){
++nLineNumber;
//経過通知
if(pcDocLineMgr.GetLineCount()>0 && nLineNumber%1024==0){
NotifyProgress(nLineNumber * 100 / pcDocLineMgr.GetLineCount());
// 処理中のユーザー操作を可能にする
if( !::BlockingHook( NULL ) ){
throw CAppExitException(); //中断検出
}
}
//1行出力 -> cmemOutputBuffer
{
// 書き込み時のコード変換 cstrSrc -> cmemOutputBuffer
EConvertResult e = pcCodeBase->UnicodeToCode(
pcDocLine->_GetDocLineDataWithEOL(),
&cmemOutputBuffer
);
if(e==RESULT_LOSESOME){
if(nRetVal==RESULT_COMPLETE)nRetVal=RESULT_LOSESOME;
}
if(e==RESULT_FAILURE){
nRetVal=RESULT_FAILURE;
ErrorMessage(
CEditWnd::getInstance()->GetHwnd(),
LS(STR_FILESAVE_CONVERT_ERROR),
//.........这里部分代码省略.........