Binary files BitcasaDiff-20140718/BitcasaDiff/BitcasaDiff.aps and BitcasaDiff-20140720/BitcasaDiff/BitcasaDiff.aps differ
diff -urN --strip-trailing-cr BitcasaDiff-20140718/BitcasaDiff/BitcasaDiff.cpp BitcasaDiff-20140720/BitcasaDiff/BitcasaDiff.cpp
--- BitcasaDiff-20140718/BitcasaDiff/BitcasaDiff.cpp	2014-07-18 01:32:52.000000000 +0900
+++ BitcasaDiff-20140720/BitcasaDiff/BitcasaDiff.cpp	2014-07-20 03:39:30.000000000 +0900
@@ -16,7 +16,7 @@
 			UINT varlen;
 			GetFileVersionInfo(exepath, 0, buflen, buf);
 			if (VerQueryValue(buf, _T("\\"), (void **)&var, &varlen)){
-				_tprintf(_T("BitcasaDiff version %d.%d.%d.%d\n\n"),
+				wprintf(L"BitcasaDiff version %d.%d.%d.%d\n\n",
 					HIWORD(var->dwProductVersionMS),
 					LOWORD(var->dwProductVersionMS),
 					HIWORD(var->dwProductVersionLS),
@@ -29,118 +29,118 @@
 	switch (mode)
 	{
 	case param::null:
-		_tprintf(_T("BitcasaDiff [ list | local | diff ]\n"));
+		wprintf(L"BitcasaDiff [ list | local | diff ]\n");
 		break;
 	case param::list:
-		_tprintf(_T("BitcasaDiff list [remotetarget]\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/remotebase (path) : set remote search basepath\n"));
-		_tprintf(_T("\t/remotetarget (target) : set remote search target\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/r : search into subdirectories\n"));
-		_tprintf(_T("\t/d : ignore directory structure.\n"));
-		_tprintf(_T("\t/regular : treat target string as regular expression\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/hash (type): download and calculate hash\n"));
-		_tprintf(_T("\t\t type=[MD5|SHA1|SHA256|SHA384|SHA512|RIPEMD160]\n"));
-		_tprintf(_T("\t/maxthread (value): set max threads for download\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/size (minsize)-(maxsize)  : size filter\n"));
-		_tprintf(_T("\t\t ex. -200 : less than or equal to 200byte\n"));
-		_tprintf(_T("\t\t     10M- : greater than or equal to 10,485,760byte\n"));
-		_tprintf(_T("\t\t     10-100 : bitween 10byte and 100byte\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/date (start)-(end) : mtime filter\n"));
-		_tprintf(_T("\t\t ex. -20100101 : before 2012/01/01 00:00:00\n"));
-		_tprintf(_T("\t\t     1980/01/01.12:00- : after 1980/01/01 12:00\n"));
-		_tprintf(_T("\t\t     19800101120000000-2012/12/31,12:30:12.000\n"));
-		_tprintf(_T("\t\t       year must be 4 digits.\n"));
-		_tprintf(_T("\t\t       month,day,hour,minute,second must be 2 digits.\n"));
-		_tprintf(_T("\t\t       millisecond must be 3 digits.\n"));
-		_tprintf(_T("\t\t       any charactor for timefield separator is ignored.\n"));
-		_tprintf(_T("\t\t       cannot use '-' and ' ' for timefield separator.\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/v : verbose output\n"));
-		_tprintf(_T("\t/faillog : output log file for download failure\n"));
+		wprintf(L"BitcasaDiff list [remotetarget]\n");
+		wprintf(L"\n");
+		wprintf(L"\t/remotebase (path) : set remote search basepath\n");
+		wprintf(L"\t/remotetarget (target) : set remote search target\n");
+		wprintf(L"\n");
+		wprintf(L"\t/r : search into subdirectories\n");
+		wprintf(L"\t/d : ignore directory structure.\n");
+		wprintf(L"\t/regular : treat target string as regular expression\n");
+		wprintf(L"\n");
+		wprintf(L"\t/hash (type): download and calculate hash\n");
+		wprintf(L"\t\t type=[MD5|SHA1|SHA256|SHA384|SHA512|RIPEMD160]\n");
+		wprintf(L"\t/maxthread (value): set max threads for download\n");
+		wprintf(L"\n");
+		wprintf(L"\t/size (minsize)-(maxsize)  : size filter\n");
+		wprintf(L"\t\t ex. -200 : less than or equal to 200byte\n");
+		wprintf(L"\t\t     10M- : greater than or equal to 10,485,760byte\n");
+		wprintf(L"\t\t     10-100 : bitween 10byte and 100byte\n");
+		wprintf(L"\n");
+		wprintf(L"\t/date (start)-(end) : mtime filter\n");
+		wprintf(L"\t\t ex. -20100101 : before 2012/01/01 00:00:00\n");
+		wprintf(L"\t\t     1980/01/01.12:00- : after 1980/01/01 12:00\n");
+		wprintf(L"\t\t     19800101120000000-2012/12/31,12:30:12.000\n");
+		wprintf(L"\t\t       year must be 4 digits.\n");
+		wprintf(L"\t\t       month,day,hour,minute,second must be 2 digits.\n");
+		wprintf(L"\t\t       millisecond must be 3 digits.\n");
+		wprintf(L"\t\t       any charactor for timefield separator is ignored.\n");
+		wprintf(L"\t\t       cannot use '-' and ' ' for timefield separator.\n");
+		wprintf(L"\n");
+		wprintf(L"\t/v : verbose output\n");
+		wprintf(L"\t/faillog : output log file for download failure\n");
 		break;
 	case param::local:
-		_tprintf(_T("BitcasaDiff local [localtarget]\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/localbase (path) : set local search basepath\n"));
-		_tprintf(_T("\t/localtarget (target) : set local search target\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/r : search into subdirectories\n"));
-		_tprintf(_T("\t/d : ignore directory structure.\n"));
-		_tprintf(_T("\t/regular : treat target string as regular expression\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/hash (type): calculate hash\n"));
-		_tprintf(_T("\t\t type=[MD5|SHA1|SHA256|SHA384|SHA512|RIPEMD160]\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/size (minsize)-(maxsize)  : size filter\n"));
-		_tprintf(_T("\t\t ex. -200 : less than or equal to 200byte\n"));
-		_tprintf(_T("\t\t     10M- : greater than or equal to 10,485,760byte\n"));
-		_tprintf(_T("\t\t     10-100 : bitween 10byte and 100byte\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/date (start)-(end) : mtime filter\n"));
-		_tprintf(_T("\t\t ex. -20100101 : before 2012/01/01 00:00:00\n"));
-		_tprintf(_T("\t\t     1980/01/01.12:00- : after 1980/01/01 12:00\n"));
-		_tprintf(_T("\t\t     19800101120000000-2012/12/31,12:30:12.000\n"));
-		_tprintf(_T("\t\t       year must be 4 digits.\n"));
-		_tprintf(_T("\t\t       month,day,hour,minute,second must be 2 digits.\n"));
-		_tprintf(_T("\t\t       millisecond must be 3 digits.\n"));
-		_tprintf(_T("\t\t       any charactor for timefield separator is ignored.\n"));
-		_tprintf(_T("\t\t       cannot use '-' and ' ' for timefield separator.\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/v : verbose output\n"));
+		wprintf(L"BitcasaDiff local [localtarget]\n");
+		wprintf(L"\n");
+		wprintf(L"\t/localbase (path) : set local search basepath\n");
+		wprintf(L"\t/localtarget (target) : set local search target\n");
+		wprintf(L"\n");
+		wprintf(L"\t/r : search into subdirectories\n");
+		wprintf(L"\t/d : ignore directory structure.\n");
+		wprintf(L"\t/regular : treat target string as regular expression\n");
+		wprintf(L"\n");
+		wprintf(L"\t/hash (type): calculate hash\n");
+		wprintf(L"\t\t type=[MD5|SHA1|SHA256|SHA384|SHA512|RIPEMD160]\n");
+		wprintf(L"\n");
+		wprintf(L"\t/size (minsize)-(maxsize)  : size filter\n");
+		wprintf(L"\t\t ex. -200 : less than or equal to 200byte\n");
+		wprintf(L"\t\t     10M- : greater than or equal to 10,485,760byte\n");
+		wprintf(L"\t\t     10-100 : bitween 10byte and 100byte\n");
+		wprintf(L"\n");
+		wprintf(L"\t/date (start)-(end) : mtime filter\n");
+		wprintf(L"\t\t ex. -20100101 : before 2012/01/01 00:00:00\n");
+		wprintf(L"\t\t     1980/01/01.12:00- : after 1980/01/01 12:00\n");
+		wprintf(L"\t\t     19800101120000000-2012/12/31,12:30:12.000\n");
+		wprintf(L"\t\t       year must be 4 digits.\n");
+		wprintf(L"\t\t       month,day,hour,minute,second must be 2 digits.\n");
+		wprintf(L"\t\t       millisecond must be 3 digits.\n");
+		wprintf(L"\t\t       any charactor for timefield separator is ignored.\n");
+		wprintf(L"\t\t       cannot use '-' and ' ' for timefield separator.\n");
+		wprintf(L"\n");
+		wprintf(L"\t/v : verbose output\n");
 		break;
 	case param::diff:
-		_tprintf(_T("BitcasaDiff diff [localtarget] [remotetarget]\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/localbase (path) : set local search basepath\n"));
-		_tprintf(_T("\t/localtarget (target) : set local search target\n"));
-		_tprintf(_T("\t/remotebase (path) : set remote search basepath\n"));
-		_tprintf(_T("\t/remotetarget (target) : set remote search target\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/regular : treat target string as regular expression\n"));
-		_tprintf(_T("\t/localregex : treat local target string as regular expression\n"));
-		_tprintf(_T("\t/remoteregex : treat local target string as regular expression\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/r : search into subdirectories(both remote and local)\n"));
-		_tprintf(_T("\t/localr : search into local subdirectories\n"));
-		_tprintf(_T("\t/remoter : search into remote subdirectories\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/d : ignore directory structure.\n"));
-		_tprintf(_T("\t/locald : ignore directory structure in local.\n"));
-		_tprintf(_T("\t/remoted : ignore directory structure in remote.\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/ignoretime : ignore time difference.\n"));
-		_tprintf(_T("\t/ignoresize : ignore size difference.\n"));
-		_tprintf(_T("\t/hash (type): download and check hash difference\n"));
-		_tprintf(_T("\t\t type=[MD5|SHA1|SHA256|SHA384|SHA512|RIPEMD160]\n"));
-		_tprintf(_T("\t/maxthread (value): set max threads for download\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/size (minsize)-(maxsize)  : size filter\n"));
-		_tprintf(_T("\t\t ex. -200 : less than or equal to 200byte\n"));
-		_tprintf(_T("\t\t     10M- : greater than or equal to 10,485,760byte\n"));
-		_tprintf(_T("\t\t     10-100 : bitween 10byte and 100byte\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/date (start)-(end) : mtime filter\n"));
-		_tprintf(_T("\t\t ex. -20100101 : before 2012/01/01 00:00:00\n"));
-		_tprintf(_T("\t\t     1980/01/01.12:00- : after 1980/01/01 12:00\n"));
-		_tprintf(_T("\t\t     19800101120000000-2012/12/31,12:30:12.000\n"));
-		_tprintf(_T("\t\t       year must be 4 digits.\n"));
-		_tprintf(_T("\t\t       month,day,hour,minute,second must be 2 digits.\n"));
-		_tprintf(_T("\t\t       millisecond must be 3 digits.\n"));
-		_tprintf(_T("\t\t       any charactor for timefield separator is ignored.\n"));
-		_tprintf(_T("\t\t       cannot use '-' and ' ' for timefield separator.\n"));
-		_tprintf(_T("\n"));
-		_tprintf(_T("\t/v : verbose output\n"));
+		wprintf(L"BitcasaDiff diff [localtarget] [remotetarget]\n");
+		wprintf(L"\n");
+		wprintf(L"\t/localbase (path) : set local search basepath\n");
+		wprintf(L"\t/localtarget (target) : set local search target\n");
+		wprintf(L"\t/remotebase (path) : set remote search basepath\n");
+		wprintf(L"\t/remotetarget (target) : set remote search target\n");
+		wprintf(L"\n");
+		wprintf(L"\t/regular : treat target string as regular expression\n");
+		wprintf(L"\t/localregex : treat local target string as regular expression\n");
+		wprintf(L"\t/remoteregex : treat local target string as regular expression\n");
+		wprintf(L"\n");
+		wprintf(L"\t/r : search into subdirectories(both remote and local)\n");
+		wprintf(L"\t/localr : search into local subdirectories\n");
+		wprintf(L"\t/remoter : search into remote subdirectories\n");
+		wprintf(L"\n");
+		wprintf(L"\t/d : ignore directory structure.\n");
+		wprintf(L"\t/locald : ignore directory structure in local.\n");
+		wprintf(L"\t/remoted : ignore directory structure in remote.\n");
+		wprintf(L"\n");
+		wprintf(L"\t/ignoretime : ignore time difference.\n");
+		wprintf(L"\t/ignoresize : ignore size difference.\n");
+		wprintf(L"\t/hash (type): download and check hash difference\n");
+		wprintf(L"\t\t type=[MD5|SHA1|SHA256|SHA384|SHA512|RIPEMD160]\n");
+		wprintf(L"\t/maxthread (value): set max threads for download\n");
+		wprintf(L"\n");
+		wprintf(L"\t/size (minsize)-(maxsize)  : size filter\n");
+		wprintf(L"\t\t ex. -200 : less than or equal to 200byte\n");
+		wprintf(L"\t\t     10M- : greater than or equal to 10,485,760byte\n");
+		wprintf(L"\t\t     10-100 : bitween 10byte and 100byte\n");
+		wprintf(L"\n");
+		wprintf(L"\t/date (start)-(end) : mtime filter\n");
+		wprintf(L"\t\t ex. -20100101 : before 2012/01/01 00:00:00\n");
+		wprintf(L"\t\t     1980/01/01.12:00- : after 1980/01/01 12:00\n");
+		wprintf(L"\t\t     19800101120000000-2012/12/31,12:30:12.000\n");
+		wprintf(L"\t\t       year must be 4 digits.\n");
+		wprintf(L"\t\t       month,day,hour,minute,second must be 2 digits.\n");
+		wprintf(L"\t\t       millisecond must be 3 digits.\n");
+		wprintf(L"\t\t       any charactor for timefield separator is ignored.\n");
+		wprintf(L"\t\t       cannot use '-' and ' ' for timefield separator.\n");
+		wprintf(L"\n");
+		wprintf(L"\t/v : verbose output\n");
 		break;
 	default:
 		break;
 	}
 
-	_tprintf(_T("\n"));
+	wprintf(L"\n");
 }
 
 void process_sizestr(_TCHAR *sizestr, param::paramdata &param)
@@ -268,7 +268,9 @@
 
 int _tmain(int argc, _TCHAR* argv[])
 {
+	//stdout
 	_setmode(_fileno(stdout), _O_U8TEXT);
+	//stderr
 	setlocale(LC_ALL, "");
 
 	// parameter initialize
@@ -309,7 +311,7 @@
 				if (datestr != NULL) {
 					process_datestr(datestr, param);
 					if (param.usedatefilter){
-						fwprintf(stderr, L" date : %s - %s\n", UTF8toWideChar(filetimestr(param.startdate)).c_str(), UTF8toWideChar(filetimestr(param.enddate)).c_str());
+						fprintf(stderr, " date : %s - %s\n", filetimestr(param.startdate).c_str(), filetimestr(param.enddate).c_str());
 					}
 				}
 				continue;
@@ -325,20 +327,20 @@
 				if (str != NULL) {
 					process_hashstr(str, param);
 					if (param.hashtype != 0){
-						_ftprintf(stderr, _T(" hash: "));
+						fprintf(stderr, " hash: ");
 						if ((param.hashtype & HashFilter::MD5) != 0)
-							_ftprintf(stderr, _T("MD5 "));
+							fprintf(stderr, "MD5 ");
 						if ((param.hashtype & HashFilter::SHA1) != 0)
-							_ftprintf(stderr, _T("SHA1 "));
+							fprintf(stderr, "SHA1 ");
 						if ((param.hashtype & HashFilter::SHA256) != 0)
-							_ftprintf(stderr, _T("SHA256 "));
+							fprintf(stderr, "SHA256 ");
 						if ((param.hashtype & HashFilter::SHA384) != 0)
-							_ftprintf(stderr, _T("SHA384 "));
+							fprintf(stderr, "SHA384 ");
 						if ((param.hashtype & HashFilter::SHA512) != 0)
-							_ftprintf(stderr, _T("SHA512 "));
+							fprintf(stderr, "SHA512 ");
 						if ((param.hashtype & HashFilter::RIPEMD160) != 0)
-							_ftprintf(stderr, _T("RIPEMD160 "));
-						_ftprintf(stderr, _T("\n"));
+							fprintf(stderr, "RIPEMD160 ");
+						fprintf(stderr, "\n");
 					}
 				}
 				continue;
@@ -373,7 +375,7 @@
 			}
 			if (_tcsicmp(&argv[i][1], _T("localregex")) == 0){
 				param.local.regular = true;
-				_ftprintf(stderr, _T(" local regular expression mode\n"));
+				fprintf(stderr, " local regular expression mode\n");
 				continue;
 			}
 			if (_tcsicmp(&argv[i][1], _T("localtarget")) == 0){
@@ -398,13 +400,13 @@
 			if (_tcsicmp(&argv[i][1], _T("regex")) == 0){
 				param.remote.regular = true;
 				param.local.regular = true;
-				_ftprintf(stderr, _T(" regular expression mode\n"));
+				fprintf(stderr, " regular expression mode\n");
 				continue;
 			}
 			if (_tcsicmp(&argv[i][1], _T("regular")) == 0){
 				param.remote.regular = true;
 				param.local.regular = true;
-				_ftprintf(stderr, _T(" regular expression mode\n"));
+				fprintf(stderr, " regular expression mode\n");
 				continue;
 			}
 			if (_tcsicmp(&argv[i][1], _T("remotebase")) == 0){
@@ -427,7 +429,7 @@
 			}
 			if (_tcsicmp(&argv[i][1], _T("remoteregex")) == 0){
 				param.remote.regular = true;
-				_ftprintf(stderr, _T(" remote regular expression mode\n"));
+				fprintf(stderr, " remote regular expression mode\n");
 				continue;
 			}
 			if (_tcsicmp(&argv[i][1], _T("remotetarget")) == 0){
Binary files BitcasaDiff-20140718/BitcasaDiff/BitcasaDiff.rc and BitcasaDiff-20140720/BitcasaDiff/BitcasaDiff.rc differ
diff -urN --strip-trailing-cr BitcasaDiff-20140718/BitcasaDiff/listBitcasa.cpp BitcasaDiff-20140720/BitcasaDiff/listBitcasa.cpp
--- BitcasaDiff-20140718/BitcasaDiff/listBitcasa.cpp	2014-07-18 19:33:14.000000000 +0900
+++ BitcasaDiff-20140720/BitcasaDiff/listBitcasa.cpp	2014-07-20 03:39:30.000000000 +0900
@@ -352,9 +352,11 @@
 
 				it.hashstr = RemoteFileHash(API, it.path, it.size, param.hashtype);
 				if (param.faillog && it.hashstr.empty()){
-					std::wofstream logfail("fail_download.log", std::ios::app);
-					if (logfail){
+					FILE* fp;
+					if (!fopen_s(&fp, "fail_download.log", "a, ccs=UTF-8")){
+						std::wofstream logfail(fp);
 						logfail << it.display << std::endl;
+						fclose(fp);
 					}
 				}
 				//std::wcerr << hashinfo << std::endl;
