Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

shellext: formatting/white space cleanup in StringUtils.cpp

Changeset 30c9e5596442

Parent 7634a4a9334d

by Adrian Buehlmann

Changes to one file · Browse files at 30c9e5596442 Showing diff from parent 7634a4a9334d Diff from another changeset...

 
29
30
31
32
33
34
35
36
37
38
39
40
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
57
 
29
30
31
 
 
 
 
 
 
 
 
 
 
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
 
 
 
 
 
 
 
 
52
53
54
55
56
57
58
59
60
61
62
63
64
@@ -29,29 +29,36 @@
 // Convert Unicode string to multibyte string  std::string WideToMultibyte(const std::wstring& wide, UINT CodePage)  { - char* narrow = NULL; - // Determine length of string - int ret = WideCharToMultiByte(CodePage, 0, wide.c_str(), static_cast<int>(wide.length()), NULL, - 0, NULL, NULL); - narrow = new char[ret + 1]; - std::auto_ptr<char> free_narrow(narrow); - ret = WideCharToMultiByte(CodePage, 0, wide.c_str(), static_cast<int>(wide.length()), narrow, - ret, NULL, NULL); - narrow[ret] = '\0'; - return narrow; + char* narrow = NULL; + // Determine length of string + int ret = WideCharToMultiByte( + CodePage, 0, wide.c_str(), static_cast<int>(wide.length()), + NULL, 0, NULL, NULL + ); + narrow = new char[ret + 1]; + std::auto_ptr<char> free_narrow(narrow); + ret = WideCharToMultiByte( + CodePage, 0, wide.c_str(), static_cast<int>(wide.length()), + narrow, ret, NULL, NULL + ); + narrow[ret] = '\0'; + return narrow;  }      // Convert multibyte string to Unicode string  std::wstring MultibyteToWide(const std::string& multibyte, UINT CodePage)  { - wchar_t* wide = NULL; - int ret = MultiByteToWideChar(CodePage, 0, multibyte.c_str(), - static_cast<int>(multibyte.length()), 0, 0); - wide = new wchar_t[ret + 1]; - std::auto_ptr<wchar_t> free_narrow(wide); - ret = MultiByteToWideChar(CodePage, 0, multibyte.c_str(), static_cast<int>(multibyte.length()), - wide, ret); - wide[ret] = L'\0'; - return wide; + wchar_t* wide = NULL; + int ret = MultiByteToWideChar( + CodePage, 0, multibyte.c_str(), + static_cast<int>(multibyte.length()), 0, 0 + ); + wide = new wchar_t[ret + 1]; + std::auto_ptr<wchar_t> free_narrow(wide); + ret = MultiByteToWideChar( + CodePage, 0, multibyte.c_str(), + static_cast<int>(multibyte.length()), wide, ret); + wide[ret] = L'\0'; + return wide;  }