From eff2799c1bc1e8374c60699a9f07bfc51619bfda Mon Sep 17 00:00:00 2001 From: Michael Mc Donnell Date: Mon, 27 Aug 2012 10:55:39 -0400 Subject: [PATCH] Update UTF 8 table generator to print char values This patch is in relation to commit 25fa8165f97 (Use char literals in UTF 8 conversion to fix 798 warnings), which changed the UTF 8 table to have char integer values instead of unsigned chars. Those values were converted using a custom Python script. This patch changes the original table generator so it can now output the same format. --- components/to_utf8/gen_iconv.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/to_utf8/gen_iconv.cpp b/components/to_utf8/gen_iconv.cpp index cc7cc191ab..dea68c1fa2 100644 --- a/components/to_utf8/gen_iconv.cpp +++ b/components/to_utf8/gen_iconv.cpp @@ -1,7 +1,6 @@ // This program generates the file tables_gen.hpp #include -#include using namespace std; #include @@ -10,9 +9,11 @@ using namespace std; void tab() { cout << " "; } // write one number with a space in front of it and a comma after it -void num(unsigned char i, bool last) +void num(char i, bool last) { - cout << " (char)0x" << (unsigned)i; + // Convert i to its integer value, i.e. -128 to 127. Printing it directly + // would result in non-printable characters in the source code, which is bad. + cout << " " << static_cast(i); if(!last) cout << ","; } @@ -80,8 +81,6 @@ int write_table(const std::string &charset, const std::string &tableName) int main() { - cout << hex; - // Write header guard cout << "#ifndef COMPONENTS_TOUTF8_TABLE_GEN_H\n#define COMPONENTS_TOUTF8_TABLE_GEN_H\n\n";