Write Unicode to text save file
This commit is contained in:
+21
-8
@@ -988,9 +988,26 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
if (!GetSaveFileName(&ofn))
|
if (!GetSaveFileName(&ofn))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
text = nh_compose_ascii_screenshot();
|
#ifdef ENHANCED_SYMBOLS
|
||||||
if (!text)
|
if (SYMHANDLING(H_UTF8)) {
|
||||||
return FALSE;
|
text = NULL;
|
||||||
|
wtext = nh_compose_unicode_screenshot();
|
||||||
|
if (!wtext)
|
||||||
|
return FALSE;
|
||||||
|
tlen = wcslen(wtext);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
text = nh_compose_ascii_screenshot();
|
||||||
|
if (!text)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
tlen = strlen(text);
|
||||||
|
wtext = (wchar_t *) malloc(tlen * sizeof(wchar_t));
|
||||||
|
if (!wtext)
|
||||||
|
panic("out of memory");
|
||||||
|
MultiByteToWideChar(NH_CODEPAGE, 0, text, -1, wtext, tlen);
|
||||||
|
}
|
||||||
|
|
||||||
pFile = _tfopen(filename, TEXT("wt+,ccs=UTF-8"));
|
pFile = _tfopen(filename, TEXT("wt+,ccs=UTF-8"));
|
||||||
if (!pFile) {
|
if (!pFile) {
|
||||||
@@ -998,14 +1015,10 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
_stprintf(buf, TEXT("Cannot open %s for writing!"), filename);
|
_stprintf(buf, TEXT("Cannot open %s for writing!"), filename);
|
||||||
NHMessageBox(hWnd, buf, MB_OK | MB_ICONERROR);
|
NHMessageBox(hWnd, buf, MB_OK | MB_ICONERROR);
|
||||||
free(text);
|
free(text);
|
||||||
|
free(wtext);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlen = strlen(text);
|
|
||||||
wtext = (wchar_t *) malloc(tlen * sizeof(wchar_t));
|
|
||||||
if (!wtext)
|
|
||||||
panic("out of memory");
|
|
||||||
MultiByteToWideChar(NH_CODEPAGE, 0, text, -1, wtext, tlen);
|
|
||||||
fwrite(wtext, tlen * sizeof(wchar_t), 1, pFile);
|
fwrite(wtext, tlen * sizeof(wchar_t), 1, pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
free(text);
|
free(text);
|
||||||
|
|||||||
Reference in New Issue
Block a user