OSDN Git Service

Add union code encode at commit support i18n.commitencoding
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / AppUtils.cpp
index b731c98..74acedb 100644 (file)
@@ -1988,4 +1988,32 @@ bool CAppUtils::SendPatchMail(CTGitPathList &list,bool autoclose)
                return true;\r
        }\r
        return false;\r
+}\r
+\r
+int CAppUtils::SaveCommitUnicodeFile(CString &filename, CString &message)\r
+{\r
+       CFile file(filename,CFile::modeReadWrite|CFile::modeCreate );\r
+       CString cmd,output;\r
+       int cp=CP_UTF8;\r
+\r
+       cmd=_T("git.exe config i18n.commitencoding");\r
+       if(g_Git.Run(cmd,&output,CP_ACP))\r
+               cp=CP_UTF8;\r
+       \r
+       int start=0;\r
+       output=output.Tokenize(_T("\n"),start);\r
+       cp=CUnicodeUtils::GetCPCode(output);    \r
+\r
+       int len=message.GetLength();\r
+\r
+       char * buf;\r
+       buf = new char[len*4 + 4];\r
+       SecureZeroMemory(buf, (len*4 + 4));\r
+\r
+       int lengthIncTerminator = WideCharToMultiByte(cp, 0, message, -1, buf, len*4, NULL, NULL);\r
+\r
+       file.Write(buf,lengthIncTerminator-1);\r
+       file.Close();\r
+       delete buf;\r
+       return 0;\r
 }
\ No newline at end of file