Changeset 2813
- Timestamp:
- 07/01/08 00:23:09 (6 months ago)
- Files:
-
- 1 modified
-
vidalia/trunk/src/tools/po2ts/po2ts.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vidalia/trunk/src/tools/po2ts/po2ts.cpp
r2792 r2813 13 13 #include <QDomDocument> 14 14 #include <QTextStream> 15 15 #include <QTextCodec> 16 16 17 17 #define TS_DOCTYPE "TS" … … 195 195 { 196 196 QTextStream error(stderr); 197 error << "usage: po2ts [-q] -i <infile.po> -o <outfile.ts>\n"; 197 error << "usage: po2ts [-q] -i <infile.po> -o <outfile.ts> " 198 "[-c <encoding>]\n"; 198 199 error << " -q (optional) Quiet mode (errors are still displayed)\n"; 199 200 error << " -i <infile.po> Input .po file\n"; 200 201 error << " -o <outfile.ts> Output .ts file\n"; 202 error << " -c <encoding> Text encoding (default: utf-8)\n"; 201 203 error.flush(); 202 204 exit(1); … … 209 211 QString errorMessage; 210 212 char *infile, *outfile; 213 QTextCodec *codec = QTextCodec::codecForName("utf-8"); 211 214 bool quiet = false; 212 215 213 216 /* Check for the correct number of input parameters. */ 214 if (argc < 5 || argc > 6)217 if (argc < 5 || argc > 8) 215 218 print_usage_and_exit(); 216 219 for (int i = 1; i < argc; i++) { … … 222 225 else if (!arg.compare("-o", Qt::CaseInsensitive) && ++i < argc) 223 226 outfile = argv[i]; 224 else 227 else if (!arg.compare("-c", Qt::CaseInsensitive) && ++i < argc) { 228 codec = QTextCodec::codecForName(argv[i]); 229 if (!codec) { 230 error << "Invalid text encoding specified\n"; 231 return 1; 232 } 233 } else 225 234 print_usage_and_exit(); 226 235 } … … 236 245 QDomDocument ts; 237 246 QTextStream po(&poFile); 247 po.setCodec(codec); 238 248 int n_strings = po2ts(&po, &ts, &errorMessage); 239 249 if (n_strings < 0) { … … 253 263 /* Write the .ts output. */ 254 264 QTextStream out(&tsFile); 255 out.setCodec("UTF-8"); 265 out.setCodec(codec); 266 out << QString("<?xml version=\"1.0\" encoding=\"%1\"?>\n") 267 .arg(QString(codec->name())); 256 268 out << ts.toString(4); 257 269
