- more updates to handle unicode (most of the focus was getting tools working in windows using non ascii file paths)

This commit is contained in:
Mark Vejvoda
2011-05-23 19:23:00 +00:00
parent 737c577099
commit 1085f24c6f
17 changed files with 321 additions and 105 deletions

View File

@@ -1832,6 +1832,13 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
fp2 = fopen(tempfileName.c_str(),"w");
#endif
if(fp1 == NULL) {
throw runtime_error("cannot open input file [" + fileName + "]");
}
if(fp2 == NULL) {
throw runtime_error("cannot open output file [" + tempfileName + "]");
}
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
buff_ptr = buffer;
if(findText != "") {
@@ -1881,14 +1888,24 @@ void copyFileTo(string fromFileName, string toFileName) {
out.put(in.get());
}
}
else if(in.is_open() == false) {
throw runtime_error("cannot open input file [" + fromFileName + "]");
}
else if(out.is_open() == false) {
throw runtime_error("cannot open input file [" + toFileName + "]");
}
//Close both files
in.close();
out.close();
#ifdef WIN32
fclose(fp1);
fclose(fp2);
if(fp1) {
fclose(fp1);
}
if(fp2) {
fclose(fp2);
}
#endif
}

View File

@@ -29,7 +29,7 @@ namespace Shared { namespace PlatformCommon {
const int IRC_SERVER_PORT = 6667;
void addlog (const char * fmt, ...) {
FILE * fp;
//FILE * fp;
char buf[1024];
va_list va_alist;

View File

@@ -53,7 +53,7 @@ LPWSTR Ansi2WideString(LPCSTR lpaszString) {
}
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr) {
std::string utf8_encode(const std::wstring wstr) {
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo( size_needed, 0 );
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
@@ -64,7 +64,7 @@ std::string utf8_encode(const std::wstring &wstr) {
}
// Convert an UTF8 string to a wide Unicode String
std::wstring utf8_decode(const std::string &str) {
std::wstring utf8_decode(const std::string str) {
string friendly_path = str;
replaceAll(friendly_path, "/", "\\");
replaceAll(friendly_path, "\\\\", "\\");