X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..b331163bffd790ced0e88b73f44f86d49ccc48a5:/icuSources/tools/genrb/wrtxml.cpp diff --git a/icuSources/tools/genrb/wrtxml.cpp b/icuSources/tools/genrb/wrtxml.cpp index 52c04ea6..1e9c5519 100644 --- a/icuSources/tools/genrb/wrtxml.cpp +++ b/icuSources/tools/genrb/wrtxml.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2002-2009, International Business Machines +* Copyright (C) 2002-2014, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -16,6 +16,17 @@ * ******************************************************************************* */ + +// Safer use of UnicodeString. +#ifndef UNISTR_FROM_CHAR_EXPLICIT +# define UNISTR_FROM_CHAR_EXPLICIT explicit +#endif + +// Less important, but still a good idea. +#ifndef UNISTR_FROM_STRING_EXPLICIT +# define UNISTR_FROM_STRING_EXPLICIT explicit +#endif + #include "reslist.h" #include "unewdata.h" #include "unicode/ures.h" @@ -25,7 +36,6 @@ #include "unicode/ucnv.h" #include "genrb.h" #include "rle.h" -#include "ucol_tok.h" #include "uhash.h" #include "uresimp.h" #include "unicode/ustring.h" @@ -33,6 +43,8 @@ #include "ustr.h" #include "prscmnts.h" #include "unicode/unistr.h" +#include "unicode/utf8.h" +#include "unicode/utf16.h" #include U_NAMESPACE_USE @@ -251,7 +263,7 @@ static char* convertAndEscape(char** pDest, int32_t destCap, int32_t* destLength return NULL; } - if((destLen+UTF8_CHAR_LENGTH(c)) < destCap){ + if((destLen+U8_LENGTH(c)) < destCap){ /* ASCII Range */ if(c <=0x007F){ @@ -674,12 +686,10 @@ array_write_xml(struct SResource *res, const char* id, const char* language, UEr int index = 0; struct SResource *current = NULL; - struct SResource *first =NULL; sid = printContainer(res, group, array_restype, NULL, id, status); current = res->u.fArray.fFirst; - first=current; while (current != NULL) { char c[256] = {0}; @@ -910,7 +920,6 @@ table_write_xml(struct SResource *res, const char* id, const char* language, UBo uint32_t i = 0; struct SResource *current = NULL; - struct SResource *save = NULL; char* sid = NULL; if (U_FAILURE(*status)) { @@ -923,7 +932,7 @@ table_write_xml(struct SResource *res, const char* id, const char* language, UBo sid[0] = '\0'; } - save = current = res->u.fTable.fFirst; + current = res->u.fTable.fFirst; i = 0; while (current != NULL) { @@ -1122,7 +1131,7 @@ bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outpu *status = U_FILE_ACCESS_ERROR; goto cleanup_bundle_write_xml; } - write_utf8_file(out, xmlHeader); + write_utf8_file(out, UnicodeString(xmlHeader)); if(outputEnc && *outputEnc!='\0'){ /* store the output encoding */ @@ -1132,9 +1141,9 @@ bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outpu goto cleanup_bundle_write_xml; } } - write_utf8_file(out, bundleStart); + write_utf8_file(out, UnicodeString(bundleStart)); write_tabs(out); - write_utf8_file(out, fileStart); + write_utf8_file(out, UnicodeString(fileStart)); /* check if lang and language are the same */ if(language != NULL && uprv_strcmp(lang, srBundle->fLocale)!=0){ fprintf(stderr,"Warning: The top level tag in the resource and language specified are not the same. Please check the input.\n"); @@ -1152,12 +1161,12 @@ bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outpu tabCount += 1; write_tabs(out); - write_utf8_file(out, headerStart); + write_utf8_file(out, UnicodeString(headerStart)); tabCount += 1; write_tabs(out); - write_utf8_file(out, tool_start); + write_utf8_file(out, UnicodeString(tool_start)); printAttribute("tool-id", tool_id, (int32_t) uprv_strlen(tool_id)); printAttribute("tool-name", tool_name, (int32_t) uprv_strlen(tool_name)); write_utf8_file(out, UnicodeString("/>\n"));