Changeset 747 in dev for trunk/ab5.0/jenga/src


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 )メソッドを追加。
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.