mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
5
Help/release/dev/nmake-utf8.rst
Normal file
5
Help/release/dev/nmake-utf8.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
nmake-utf8
|
||||||
|
----------
|
||||||
|
|
||||||
|
* The :generator:`NMake Makefiles` generator now encodes the generated
|
||||||
|
makefiles as UTF-8 with a BOM when using ``nmake`` from VS 9 or above.
|
@@ -42,6 +42,11 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name,
|
|||||||
#else
|
#else
|
||||||
static_cast<void>(encoding);
|
static_cast<void>(encoding);
|
||||||
#endif
|
#endif
|
||||||
|
if (encoding == codecvt::UTF8_WITH_BOM) {
|
||||||
|
// Write the BOM encoding header into the file
|
||||||
|
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
|
||||||
|
this->write(magic, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGeneratedFileStream::~cmGeneratedFileStream()
|
cmGeneratedFileStream::~cmGeneratedFileStream()
|
||||||
|
@@ -31,7 +31,7 @@ public:
|
|||||||
/** Get encoding used by generator for makefile files */
|
/** Get encoding used by generator for makefile files */
|
||||||
codecvt::Encoding GetMakefileEncoding() const override
|
codecvt::Encoding GetMakefileEncoding() const override
|
||||||
{
|
{
|
||||||
return codecvt::ANSI;
|
return this->NMakeSupportsUTF8 ? codecvt::UTF8_WITH_BOM : codecvt::ANSI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the documentation entry for this generator. */
|
/** Get the documentation entry for this generator. */
|
||||||
|
@@ -2058,7 +2058,8 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
|
|||||||
// Create the response file.
|
// Create the response file.
|
||||||
std::string responseFileNameFull =
|
std::string responseFileNameFull =
|
||||||
cmStrCat(this->TargetBuildDirectoryFull, '/', name);
|
cmStrCat(this->TargetBuildDirectoryFull, '/', name);
|
||||||
cmGeneratedFileStream responseStream(responseFileNameFull);
|
cmGeneratedFileStream responseStream(
|
||||||
|
responseFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
|
||||||
responseStream.SetCopyIfDifferent(true);
|
responseStream.SetCopyIfDifferent(true);
|
||||||
responseStream << options << "\n";
|
responseStream << options << "\n";
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ codecvt::codecvt(Encoding e)
|
|||||||
// We don't know which ANSI encoding to use for other platforms than
|
// We don't know which ANSI encoding to use for other platforms than
|
||||||
// Windows so we don't do any conversion there
|
// Windows so we don't do any conversion there
|
||||||
case codecvt::UTF8:
|
case codecvt::UTF8:
|
||||||
|
case codecvt::UTF8_WITH_BOM:
|
||||||
// Assume internal encoding is UTF-8
|
// Assume internal encoding is UTF-8
|
||||||
case codecvt::None:
|
case codecvt::None:
|
||||||
// No encoding
|
// No encoding
|
||||||
|
@@ -14,6 +14,7 @@ public:
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
UTF8,
|
UTF8,
|
||||||
|
UTF8_WITH_BOM,
|
||||||
ANSI
|
ANSI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user