回答編集履歴
2
修正案の追加
test
CHANGED
@@ -2,15 +2,13 @@
|
|
2
2
|
|
3
3
|
filter += string( "label" );
|
4
4
|
|
5
|
-
filter
|
5
|
+
filter.push_back( '\0' );
|
6
6
|
|
7
7
|
filter += string( "*.ext" );
|
8
8
|
|
9
|
-
filter
|
9
|
+
filter.push_back( '\0' );
|
10
10
|
|
11
|
-
```
|
12
|
-
|
13
|
-
これでヌル文字を強制的に埋め込めます。何行も書くのが嫌なら、
|
11
|
+
```これでヌル文字を強制的に埋め込めます。何行も書くのが嫌なら、
|
14
12
|
|
15
13
|
```C++
|
16
14
|
|
@@ -30,6 +28,24 @@
|
|
30
28
|
|
31
29
|
}
|
32
30
|
|
33
|
-
```
|
31
|
+
```と置換を利用する手もあります。
|
34
32
|
|
33
|
+
|
34
|
+
|
35
|
+
どちらも嫌なら、
|
36
|
+
|
37
|
+
```C++
|
38
|
+
|
39
|
+
#define STLFILTERSTR(a) (std::string((a), sizeof(a)-sizeof((a)[0])))
|
40
|
+
|
41
|
+
filter += STLFILTERSTR( "All [ *.* ]\0*.*\0\0" )
|
42
|
+
|
35
|
-
|
43
|
+
```なんて方法もあります。
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
参考URL:
|
48
|
+
|
49
|
+
http://stackoverflow.com/questions/164168/how-do-you-construct-a-stdstring-with-an-embedded-null
|
50
|
+
|
51
|
+
http://stackoverflow.com/questions/17403066/strange-behavior-on-adding-0-to-stdstring
|
1
バグの修正
test
CHANGED
@@ -16,7 +16,19 @@
|
|
16
16
|
|
17
17
|
filter += string( "All [ *.* ]\t*.*\t\t" );
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
size_t i = 0;
|
22
|
+
|
23
|
+
for( i = 0; i < filter.length(); i++ ){
|
24
|
+
|
25
|
+
if( filter[i] == '\t' ){
|
26
|
+
|
19
|
-
filter
|
27
|
+
filter[i] = '\0';
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
}
|
20
32
|
|
21
33
|
```
|
22
34
|
|