-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString.cpp
More file actions
46 lines (37 loc) · 1.16 KB
/
String.cpp
File metadata and controls
46 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "stdafx.h"
#include "String.h"
namespace w32
{
//convert a wstring to a string
string WStringToString(wstring const& ws) {
wstring_convert<codecvt_utf8_utf16<wchar_t>> converter;
return converter.to_bytes(ws.c_str());
}
//convert a string to wstring
wstring StringToWString(string const& s) {
wstring_convert<codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(s.c_str());
}
//convert to lowercase
void ToLowerInPlace(string& s) {
transform(s.begin(), s.end(), s.begin(), ::tolower);
}
//convert to uppercase
void ToUpperInPlace(string& s) {
transform(s.begin(), s.end(), s.begin(), ::toupper);
}
//convert to lowercase
void ToWLowerInPlace(wstring& ws) {
transform(ws.begin(), ws.end(), ws.begin(), towlower);
}
//convert to uppercase
void ToWUpperInPlace(wstring& ws) {
transform(ws.begin(), ws.end(), ws.begin(), towupper);
}
//surround an input string with marks
wstring SurroundWith(wstring val, wstring mark) {
wstringstream wss;
wss << mark << val << mark;
return wss.str();
}
}