UNICODE字符和ASCII字符的转换

// Database object

HRESULT CDB::Read(short nTable, short nRow, LPWSTR lpszData) {

  CStringArray *pTable;

  pTable=(CStringArray*) m_arrTables[nTable];

#ifndef UNICODE

    MultiByteToWideChar(CP_ACP, 0, (*pTable)[nRow], -1, lpszData, 80);

#else

  lstrcpy (lpszData, (*pTable)[nRow]);

#endif

  return NO_ERROR;

}



HRESULT CDB::Write(short nTable, short nRow, LPCWSTR lpszData) {

  CStringArray *pTable;

  pTable=(CStringArray*) m_arrTables[nTable];

#ifdef UNICODE

  pTable->SetAtGrow(nRow, lpszData);

#else

    char szData[80];

    WideCharToMultiByte(CP_ACP, 0, lpszData, -1, szData, 80, NULL, NULL);

  pTable->SetAtGrow(nRow, szData);

#endif

  return NO_ERROR;

}

 

你可能感兴趣的:(unicode)