summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratedFileStream.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-28 23:52:33 (GMT)
committerBrad King <brad.king@kitware.com>2022-10-29 00:23:25 (GMT)
commit328c15189d661503fbf6561731e550064e6a5567 (patch)
tree876f941e11bc55249e49a212687e191d682317a9 /Source/cmGeneratedFileStream.cxx
parent59ae2543165b836d01b88fe0ba4e22ecd549e239 (diff)
downloadCMake-328c15189d661503fbf6561731e550064e6a5567.zip
CMake-328c15189d661503fbf6561731e550064e6a5567.tar.gz
CMake-328c15189d661503fbf6561731e550064e6a5567.tar.bz2
cmGeneratedFileStream: Add support for a temporary alternate encoding
The Ninja generator needs to be able to write some file content in a different encoding than the rest of the file. Add a method to do this.
Diffstat (limited to 'Source/cmGeneratedFileStream.cxx')
-rw-r--r--Source/cmGeneratedFileStream.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 6212bbd..215c3c2 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -239,6 +239,20 @@ void cmGeneratedFileStream::SetTempExt(std::string const& ext)
this->TempExt = ext;
}
+void cmGeneratedFileStream::WriteAltEncoding(std::string const& data,
+ Encoding encoding)
+{
+#ifndef CMAKE_BOOTSTRAP
+ std::locale prevLocale =
+ this->imbue(std::locale(this->getloc(), new codecvt(encoding)));
+ this->write(data.data(), data.size());
+ this->imbue(prevLocale);
+#else
+ static_cast<void>(encoding);
+ this->write(data.data(), data.size());
+#endif
+}
+
void cmGeneratedFileStream::WriteRaw(std::string const& data)
{
#ifndef CMAKE_BOOTSTRAP