source: dev/trunk/ab5.0/jenga/src/common/String.cpp@ 590

Last change on this file since 590 was 590, checked in by dai_9181, 16 years ago

ToWString関数を追加。

File size: 999 bytes
Line 
1#include "stdafx.h"
2
3bool Jenga::Common::IsExistString( const Jenga::Common::Strings &strings, const std::string &findStr )
4{
5 BOOST_FOREACH( const std::string &str, strings )
6 {
7 if( str == findStr )
8 {
9 return true;
10 }
11 }
12 return false;
13}
14
15std::string& Jenga::Common::StringReplace( std::string& str, const std::string sb, const std::string sa )
16{
17 std::string::size_type n, nb = 0;
18
19 while ((n = str.find(sb,nb)) != std::string::npos)
20 {
21 str.replace(n,sb.size(),sa);
22 nb = n + sa.size();
23 }
24
25 return str;
26}
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 TracBrowser for help on using the repository browser.