mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[dos] fix assert when system locale is set to UTF-8
* Recent versions of Windows can set the deafult locale to codepage 65001 (UTF-8). * This produces an assert due to a missing entry in cp_hr_list[], so fix that. * However, this fix alone is not enough, as a GetOEMCP() that returns 65001 means that any systems set to UTF-8 will fall back to codepage 437 for DOS, which is definitely not what we want => Add an extra call to determine the actual OEM codepage when UTF-8 is detected. * Closes #1468
This commit is contained in:
parent
cd4ab21e3c
commit
5681c3ba41
2 changed files with 16 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Rufus: The Reliable USB Formatting Utility
|
* Rufus: The Reliable USB Formatting Utility
|
||||||
* DOS keyboard locale setup
|
* DOS keyboard locale setup
|
||||||
* Copyright © 2011-2013 Pete Batard <pete@akeo.ie>
|
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -419,7 +419,8 @@ static cp_list cp_hr_list[] = {
|
||||||
{ 59829, "Georgian"},
|
{ 59829, "Georgian"},
|
||||||
{ 60258, "Lat-Azeri"},
|
{ 60258, "Lat-Azeri"},
|
||||||
{ 60853, "Georgian (Alt)"},
|
{ 60853, "Georgian (Alt)"},
|
||||||
{ 62306, "Cyr-Uzbek"}
|
{ 62306, "Cyr-Uzbek"},
|
||||||
|
{ 65001, "Unicode (UTF-8)" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* cp_to_hr(ULONG cp)
|
static const char* cp_to_hr(ULONG cp)
|
||||||
|
@ -961,13 +962,13 @@ static ULONG fd_upgrade_cp(ULONG cp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Don't bother about setting up the country or multiple codepages
|
// Don't bother about setting up the country or multiple codepages
|
||||||
BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
|
BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
|
||||||
{
|
{
|
||||||
FILE* fd;
|
FILE* fd;
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
ULONG cp;
|
ULONG cp;
|
||||||
|
UINT actual_cp;
|
||||||
const char *kb;
|
const char *kb;
|
||||||
int kbdrv;
|
int kbdrv;
|
||||||
const char* egadrv;
|
const char* egadrv;
|
||||||
|
@ -985,6 +986,13 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
|
||||||
|
|
||||||
// Now get a codepage
|
// Now get a codepage
|
||||||
cp = GetOEMCP();
|
cp = GetOEMCP();
|
||||||
|
if (cp == 65001) {
|
||||||
|
// GetOEMCP() may return UTF-8 for the codepage (65001),
|
||||||
|
// in which case we need to find the actual system OEM cp.
|
||||||
|
if (GetLocaleInfoA(GetUserDefaultUILanguage(), LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
|
||||||
|
(char*)&actual_cp, sizeof(actual_cp)))
|
||||||
|
cp = actual_cp;
|
||||||
|
}
|
||||||
egadrv = bFreeDOS?fd_get_ega(cp):ms_get_ega(cp);
|
egadrv = bFreeDOS?fd_get_ega(cp):ms_get_ega(cp);
|
||||||
if (egadrv == NULL) {
|
if (egadrv == NULL) {
|
||||||
// We need to use the fallback CP from the keyboard we got above, as 437 is not always available
|
// We need to use the fallback CP from the keyboard we got above, as 437 is not always available
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.9.1625"
|
CAPTION "Rufus 3.9.1626"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -395,8 +395,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,9,1625,0
|
FILEVERSION 3,9,1626,0
|
||||||
PRODUCTVERSION 3,9,1625,0
|
PRODUCTVERSION 3,9,1626,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -414,13 +414,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.9.1625"
|
VALUE "FileVersion", "3.9.1626"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.9.exe"
|
VALUE "OriginalFilename", "rufus-3.9.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.9.1625"
|
VALUE "ProductVersion", "3.9.1626"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue