Changeset 590 in dev


Ignore:
Timestamp:
May 10, 2008, 5:53:17 PM (17 years ago)
Author:
dai_9181
Message:

ToWString関数を追加。

Location:
trunk/ab5.0/jenga
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/jenga/include/common/String.h

    r524 r590  
    1111std::string& StringReplace( std::string& str, const std::string sb, const std::string sa );
    1212
     13std::wstring ToWString( const std::string &str );
     14
    1315
    1416}
  • trunk/ab5.0/jenga/src/common/String.cpp

    r518 r590  
    2525    return str;
    2626}
     27
     28std::wstring Jenga::Common::ToWString( const std::string &str )
     29{
     30    int size = MultiByteToWideChar(
     31        CP_ACP,
     32        0,
     33        str.c_str(), static_cast<int>(str.size()) + 1,
     34        NULL, 0 ) * 2;
     35
     36    LPWSTR pwstr = (LPWSTR)malloc( size );
     37
     38    MultiByteToWideChar(
     39        CP_ACP,
     40        0,
     41        str.c_str(), static_cast<int>(str.size()) + 1,
     42        pwstr, static_cast<int>(str.size()) + 1 );
     43
     44    std::wstring wstr( pwstr, str.size() );
     45
     46    free( pwstr );
     47
     48    return wstr;
     49}
Note: See TracChangeset for help on using the changeset viewer.