Changeset 747 in dev for trunk


Ignore:
Timestamp:
Sep 15, 2008, 4:41:01 PM (16 years ago)
Author:
dai
Message:
  • Unicodeの文字列をデータテーブルに挿入する際、コピーするサイズが半減してしまう不具合を修正。
  • std::string Jenga::Common::ToString( const std::wstring &wstr )メソッドを追加。
Location:
trunk/ab5.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/ab_common/src/Lexical/DataTable.cpp

    r700 r747  
    3939int DataTable::AddWString( const std::wstring &wstr )
    4040{
    41     return AddBinary( wstr.c_str(), static_cast<int>(wstr.size()) + sizeof(wchar_t) );
     41    return AddBinary( wstr.c_str(), static_cast<int>((wstr.length()+1)*sizeof(wchar_t)));
    4242}
    4343int DataTable::AddSpace( int size )
  • trunk/ab5.0/jenga/include/common/String.h

    r622 r747  
    1212
    1313std::string ToString( int n );
     14std::string ToString( const std::wstring &wstr );
    1415std::wstring ToWString( const std::string &str );
    1516
  • trunk/ab5.0/jenga/src/common/String.cpp

    r745 r747  
    3333}
    3434
     35std::string Jenga::Common::ToString( const std::wstring &wstr )
     36{
     37    char *pstr = (char *)malloc( wstr.length() + 1 );
     38
     39    WideCharToMultiByte(
     40        CP_ACP,
     41        0,
     42        wstr.c_str(), -1,
     43        pstr, static_cast<int>(wstr.length()) + 1,
     44        NULL, NULL );
     45
     46    std::string result = pstr;
     47
     48    free( pstr );
     49
     50    return result;
     51}
     52
    3553std::wstring Jenga::Common::ToWString( const std::string &str )
    3654{
     
    4159        NULL, 0 ) * 4;
    4260
    43     LPWSTR pwstr = (LPWSTR)malloc( size );
     61    LPWSTR pwstr = (LPWSTR)calloc( size, 1 );
    4462
    4563    MultiByteToWideChar(
Note: See TracChangeset for help on using the changeset viewer.