[Cmake-commits] CMake branch, next, updated. v2.8.12.1-6432-g2ba55c5
Nils Gladitz
nilsgladitz at gmail.com
Thu Dec 26 09:25:36 EST 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 2ba55c5f613f3e6d6e3cf471e6e60d4304051535 (commit)
via 950d76ed485bd98498fefa1eb63d86bda83d9159 (commit)
from d1a4be8cdfe853108bc99d737f30e849c760d490 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ba55c5f613f3e6d6e3cf471e6e60d4304051535
commit 2ba55c5f613f3e6d6e3cf471e6e60d4304051535
Merge: d1a4be8 950d76e
Author: Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Dec 26 09:25:34 2013 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Dec 26 09:25:34 2013 -0500
Merge topic 'wix-rtf-encoding' into next
950d76e CPackWiX: allow and convert UTF-8 sequences in RTF writer
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=950d76ed485bd98498fefa1eb63d86bda83d9159
commit 950d76ed485bd98498fefa1eb63d86bda83d9159
Author: Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Dec 26 15:23:54 2013 +0100
Commit: Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Thu Dec 26 15:23:54 2013 +0100
CPackWiX: allow and convert UTF-8 sequences in RTF writer
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake
index d9e0ba7..30f57c7 100644
--- a/Modules/CPackWIX.cmake
+++ b/Modules/CPackWIX.cmake
@@ -52,6 +52,7 @@
#
# If CPACK_RESOURCE_FILE_LICENSE has an .txt extension it is implicitly
# converted to RTF by the WiX Generator.
+# The expected encoding of the .txt file is UTF-8.
#
# With CPACK_WIX_LICENSE_RTF you can override the license file used by the
# WiX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index 886b534..ddc1d71 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -65,7 +65,41 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text)
}
else
{
- File << "[NON-ASCII-" << int(c) << "]";
+ if(c <= 0xC0)
+ {
+ EmitInvalidCodepoint(c);
+ }
+ else if(c < 0xE0 && i+1 < text.size())
+ {
+ EmitUnicodeCodepoint(
+ (text[i+1] & 0x3F) |
+ ((c & 0x1F) << 6)
+ );
+ i+= 1;
+ }
+ else if(c < 0xF0 && i+2 < text.size())
+ {
+ EmitUnicodeCodepoint(
+ (text[i+2] & 0x3F) |
+ ((text[i+1] & 0x3F) << 6) |
+ ((c & 0xF) << 12)
+ );
+ i += 2;
+ }
+ else if(c < 0xF8 && i+3 < text.size())
+ {
+ EmitUnicodeCodepoint(
+ (text[i+3] & 0x3F) |
+ ((text[i+2] & 0x3F) << 6) |
+ ((text[i+1] & 0x3F) << 12) |
+ ((c & 0x7) << 18)
+ );
+ i += 3;
+ }
+ else
+ {
+ EmitInvalidCodepoint(c);
+ }
}
}
break;
@@ -82,6 +116,7 @@ void cmWIXRichTextFormatWriter::WriteHeader()
ControlWord("deflang1031");
WriteFontTable();
+ WriteColorTable();
WriteGenerator();
}
@@ -99,6 +134,22 @@ void cmWIXRichTextFormatWriter::WriteFontTable()
EndGroup();
}
+void cmWIXRichTextFormatWriter::WriteColorTable()
+{
+ StartGroup();
+ ControlWord("colortbl ;");
+ ControlWord("red255");
+ ControlWord("green0");
+ ControlWord("blue0;");
+ ControlWord("red0");
+ ControlWord("green255");
+ ControlWord("blue0;");
+ ControlWord("red0");
+ ControlWord("green0");
+ ControlWord("blue255;");
+ EndGroup();
+}
+
void cmWIXRichTextFormatWriter::WriteGenerator()
{
StartGroup();
@@ -135,3 +186,43 @@ void cmWIXRichTextFormatWriter::EndGroup()
{
File.put('}');
}
+
+void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
+{
+ // Do not emit byte order mark (BOM)
+ if(c == 0xFEFF)
+ {
+ return;
+ }
+ else if(c <= 0xFFFF)
+ {
+ EmitUnicodeSurrogate(c);
+ }
+ else
+ {
+ c -= 0x10000;
+ EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800);
+ EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00);
+ }
+}
+
+void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
+{
+ ControlWord("u");
+ if(c <= 32767)
+ {
+ File << c;
+ }
+ else
+ {
+ File << (c - 65536);
+ }
+ File << "?";
+}
+
+void cmWIXRichTextFormatWriter::EmitInvalidCodepoint(int c)
+{
+ ControlWord("cf1 ");
+ File << "[INVALID-BYTE-" << int(c) << "]";
+ ControlWord("cf0 ");
+}
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index bb8580a..38e40b0 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -30,6 +30,7 @@ public:
private:
void WriteHeader();
void WriteFontTable();
+ void WriteColorTable();
void WriteGenerator();
void WriteDocumentPrefix();
@@ -40,6 +41,11 @@ private:
void StartGroup();
void EndGroup();
+ void EmitUnicodeCodepoint(int c);
+ void EmitUnicodeSurrogate(int c);
+
+ void EmitInvalidCodepoint(int c);
+
std::ofstream File;
};
diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt
index 0b06045..bc3322e 100644
--- a/Tests/CPackWiXGenerator/CMakeLists.txt
+++ b/Tests/CPackWiXGenerator/CMakeLists.txt
@@ -51,6 +51,8 @@ set(CPACK_PACKAGE_EXECUTABLES
set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt")
+
include(CPack)
cpack_add_install_type(Full DISPLAY_NAME "Everything")
diff --git a/Tests/CPackWiXGenerator/license.txt b/Tests/CPackWiXGenerator/license.txt
new file mode 100644
index 0000000..7942783
--- /dev/null
+++ b/Tests/CPackWiXGenerator/license.txt
@@ -0,0 +1,9 @@
+hello world
+merhaba dünya
+ハローワールド
+привет мир
+مرحبا العالم
+你好世界
+
+4-Byte sequences:
+ Perch (Fish) 𩶘 Elevator 𨋢!
-----------------------------------------------------------------------
Summary of changes:
Modules/CPackWIX.cmake | 1 +
Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx | 93 +++++++++++++++++++++++-
Source/CPack/WiX/cmWIXRichTextFormatWriter.h | 6 ++
Tests/CPackWiXGenerator/CMakeLists.txt | 2 +
Tests/CPackWiXGenerator/license.txt | 9 +++
5 files changed, 110 insertions(+), 1 deletions(-)
create mode 100644 Tests/CPackWiXGenerator/license.txt
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list