Explorar o código

Encoding: Remove option to use ANSI code page internally

The switch to use UTF-8 encoding has been defaulted to on for quite some
time since commit v3.2.0-rc1~116^2 (Encoding: Switch to use UTF-8
internally by default on Windows, 2014-12-26).
Clinton Stimpson %!s(int64=9) %!d(string=hai) anos
pai
achega
baead1e2a8

+ 2 - 6
CMakeLists.txt

@@ -66,12 +66,8 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
   include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake)
 endif()
 
-# option to set the internal encoding of CMake to UTF-8
-option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally." ON)
-mark_as_advanced(CMAKE_ENCODING_UTF8)
-if(CMAKE_ENCODING_UTF8)
-  set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
-endif()
+# set the internal encoding of CMake to UTF-8
+set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
 
 # option to use COMPONENT with install command
 option(CMake_INSTALL_COMPONENTS "Using components when installing" OFF)

+ 1 - 2
Source/CPack/WiX/cmCPackWIXGenerator.cxx

@@ -410,8 +410,7 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
   std::ostringstream tmp;
   tmp << name << "=\"" << value << '"';
 
-  source.AddProcessingInstruction(
-    "define", cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str()));
+  source.AddProcessingInstruction("define", tmp.str());
 }
 
 bool cmCPackWIXGenerator::CreateWiXSourceFiles()

+ 1 - 40
Source/CPack/WiX/cmWIXSourceWriter.cxx

@@ -117,9 +117,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
 void cmWIXSourceWriter::AddAttribute(std::string const& key,
                                      std::string const& value)
 {
-  std::string utf8 = CMakeEncodingToUtf8(value);
-
-  File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
+  File << " " << key << "=\"" << EscapeAttributeValue(value) << '"';
 }
 
 void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,
@@ -130,43 +128,6 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,
   }
 }
 
-std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
-{
-#ifdef CMAKE_ENCODING_UTF8
-  return value;
-#else
-  if (value.empty()) {
-    return std::string();
-  }
-
-  int characterCount = MultiByteToWideChar(
-    CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0);
-
-  if (characterCount == 0) {
-    return std::string();
-  }
-
-  std::vector<wchar_t> utf16(characterCount);
-
-  MultiByteToWideChar(CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
-                      &utf16[0], static_cast<int>(utf16.size()));
-
-  int utf8ByteCount = WideCharToMultiByte(
-    CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0);
-
-  if (utf8ByteCount == 0) {
-    return std::string();
-  }
-
-  std::vector<char> utf8(utf8ByteCount);
-
-  WideCharToMultiByte(CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()),
-                      &utf8[0], static_cast<int>(utf8.size()), 0, 0);
-
-  return std::string(&utf8[0], utf8.size());
-#endif
-}
-
 std::string cmWIXSourceWriter::CreateGuidFromComponentId(
   std::string const& componentId)
 {

+ 0 - 2
Source/CPack/WiX/cmWIXSourceWriter.h

@@ -50,8 +50,6 @@ public:
 
   std::string CreateGuidFromComponentId(std::string const& componentId);
 
-  static std::string CMakeEncodingToUtf8(std::string const& value);
-
 protected:
   cmCPackLog* Logger;
 

+ 0 - 2
Source/QtDialog/CMakeSetup.cxx

@@ -95,10 +95,8 @@ int main(int argc, char** argv)
 
   setlocale(LC_NUMERIC, "C");
 
-#if defined(CMAKE_ENCODING_UTF8)
   QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
   QTextCodec::setCodecForLocale(utf8_codec);
-#endif
 
 #if QT_VERSION < 0x050000
   // clean out standard Qt paths for plugins, which we don't use anyway

+ 0 - 1
Source/cmConfigure.cmake.h.in

@@ -20,7 +20,6 @@
 #cmakedefine CMAKE_USE_ELF_PARSER
 #cmakedefine CMAKE_USE_MACH_PARSER
 #cmakedefine CMAKE_USE_LIBUV
-#cmakedefine CMAKE_ENCODING_UTF8
 #cmakedefine CMake_HAVE_CXX_AUTO_PTR
 #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE
 #cmakedefine CMake_HAVE_CXX_NULLPTR

+ 3 - 3
Source/cmFileCommand.cxx

@@ -59,7 +59,7 @@ static mode_t mode_setuid = S_ISUID;
 static mode_t mode_setgid = S_ISGID;
 #endif
 
-#if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8)
+#if defined(_WIN32)
 // libcurl doesn't support file:// urls for unicode filenames on Windows.
 // Convert string from UTF-8 to ACP if this is a file:// URL.
 static std::string fix_file_url_windows(const std::string& url)
@@ -2642,7 +2642,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
     return false;
   }
 
-#if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8)
+#if defined(_WIN32)
   url = fix_file_url_windows(url);
 #endif
 
@@ -2902,7 +2902,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
 
   unsigned long file_size = cmsys::SystemTools::FileLength(filename);
 
-#if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8)
+#if defined(_WIN32)
   url = fix_file_url_windows(url);
 #endif
 

+ 1 - 7
Source/cmGlobalVisualStudio7Generator.cxx

@@ -731,11 +731,5 @@ bool cmGlobalVisualStudio7Generator::IsDependedOn(
 
 std::string cmGlobalVisualStudio7Generator::Encoding()
 {
-  std::ostringstream encoding;
-#ifdef CMAKE_ENCODING_UTF8
-  encoding << "UTF-8";
-#else
-  encoding << "Windows-1252";
-#endif
-  return encoding.str();
+  return "UTF-8";
 }