On Wed, 2014-03-05 at 18:07 +0900, Dmitry Timoshkov wrote:
+static HRESULT write_xml_utf8(const WCHAR *name, DWORD disposition, const WCHAR *xmlW) +{
- static const char bom_utf8[] = { 0xef,0xbb,0xbf };
- static const char comment[] = "<!-- Task definition created by Wine -->\n";
- HANDLE hfile;
- DWORD size;
- char *xml;
- HRESULT hr = S_OK;
- hfile = CreateFileW(name, GENERIC_WRITE, 0, NULL, disposition, 0, 0);
- if (hfile == INVALID_HANDLE_VALUE)
- {
if (GetLastError() == ERROR_FILE_EXISTS)
return HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS);
return HRESULT_FROM_WIN32(GetLastError());
- }
- size = WideCharToMultiByte(CP_UTF8, 0, xmlW, -1, NULL, 0, NULL, NULL);
- xml = heap_alloc(size);
- if (!xml)
- {
CloseHandle(hfile);
return E_OUTOFMEMORY;
- }
- WideCharToMultiByte(CP_UTF8, 0, xmlW, -1, xml, size, NULL, NULL);
- if (!WriteFile(hfile, bom_utf8, strlen(bom_utf8), &size, NULL))
bom_utf8 is not null-terminated.