| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 2002-2012, International Business Machines | 4 * Copyright (C) 2002-2014, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * | 8 * |
| 9 * File wrtxml.cpp | 9 * File wrtxml.cpp |
| 10 * | 10 * |
| 11 * Modification History: | 11 * Modification History: |
| 12 * | 12 * |
| 13 * Date Name Description | 13 * Date Name Description |
| 14 * 10/01/02 Ram Creation. | 14 * 10/01/02 Ram Creation. |
| 15 * 02/07/08 Spieth Correct XLIFF generation on EBCDIC platform | 15 * 02/07/08 Spieth Correct XLIFF generation on EBCDIC platform |
| 16 * | 16 * |
| 17 ******************************************************************************* | 17 ******************************************************************************* |
| 18 */ | 18 */ |
| 19 |
| 20 // Safer use of UnicodeString. |
| 21 #ifndef UNISTR_FROM_CHAR_EXPLICIT |
| 22 # define UNISTR_FROM_CHAR_EXPLICIT explicit |
| 23 #endif |
| 24 |
| 25 // Less important, but still a good idea. |
| 26 #ifndef UNISTR_FROM_STRING_EXPLICIT |
| 27 # define UNISTR_FROM_STRING_EXPLICIT explicit |
| 28 #endif |
| 29 |
| 19 #include "reslist.h" | 30 #include "reslist.h" |
| 20 #include "unewdata.h" | 31 #include "unewdata.h" |
| 21 #include "unicode/ures.h" | 32 #include "unicode/ures.h" |
| 22 #include "errmsg.h" | 33 #include "errmsg.h" |
| 23 #include "filestrm.h" | 34 #include "filestrm.h" |
| 24 #include "cstring.h" | 35 #include "cstring.h" |
| 25 #include "unicode/ucnv.h" | 36 #include "unicode/ucnv.h" |
| 26 #include "genrb.h" | 37 #include "genrb.h" |
| 27 #include "rle.h" | 38 #include "rle.h" |
| 28 #include "ucol_tok.h" | |
| 29 #include "uhash.h" | 39 #include "uhash.h" |
| 30 #include "uresimp.h" | 40 #include "uresimp.h" |
| 31 #include "unicode/ustring.h" | 41 #include "unicode/ustring.h" |
| 32 #include "unicode/uchar.h" | 42 #include "unicode/uchar.h" |
| 33 #include "ustr.h" | 43 #include "ustr.h" |
| 34 #include "prscmnts.h" | 44 #include "prscmnts.h" |
| 35 #include "unicode/unistr.h" | 45 #include "unicode/unistr.h" |
| 36 #include "unicode/utf8.h" | 46 #include "unicode/utf8.h" |
| 37 #include "unicode/utf16.h" | 47 #include "unicode/utf16.h" |
| 38 #include <time.h> | 48 #include <time.h> |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 if (U_FAILURE(*status)) { | 1124 if (U_FAILURE(*status)) { |
| 1115 goto cleanup_bundle_write_xml; | 1125 goto cleanup_bundle_write_xml; |
| 1116 } | 1126 } |
| 1117 | 1127 |
| 1118 out= T_FileStream_open(xmlfileName,"w"); | 1128 out= T_FileStream_open(xmlfileName,"w"); |
| 1119 | 1129 |
| 1120 if(out==NULL){ | 1130 if(out==NULL){ |
| 1121 *status = U_FILE_ACCESS_ERROR; | 1131 *status = U_FILE_ACCESS_ERROR; |
| 1122 goto cleanup_bundle_write_xml; | 1132 goto cleanup_bundle_write_xml; |
| 1123 } | 1133 } |
| 1124 write_utf8_file(out, xmlHeader); | 1134 write_utf8_file(out, UnicodeString(xmlHeader)); |
| 1125 | 1135 |
| 1126 if(outputEnc && *outputEnc!='\0'){ | 1136 if(outputEnc && *outputEnc!='\0'){ |
| 1127 /* store the output encoding */ | 1137 /* store the output encoding */ |
| 1128 enc = outputEnc; | 1138 enc = outputEnc; |
| 1129 conv=ucnv_open(enc,status); | 1139 conv=ucnv_open(enc,status); |
| 1130 if(U_FAILURE(*status)){ | 1140 if(U_FAILURE(*status)){ |
| 1131 goto cleanup_bundle_write_xml; | 1141 goto cleanup_bundle_write_xml; |
| 1132 } | 1142 } |
| 1133 } | 1143 } |
| 1134 write_utf8_file(out, bundleStart); | 1144 write_utf8_file(out, UnicodeString(bundleStart)); |
| 1135 write_tabs(out); | 1145 write_tabs(out); |
| 1136 write_utf8_file(out, fileStart); | 1146 write_utf8_file(out, UnicodeString(fileStart)); |
| 1137 /* check if lang and language are the same */ | 1147 /* check if lang and language are the same */ |
| 1138 if(language != NULL && uprv_strcmp(lang, srBundle->fLocale)!=0){ | 1148 if(language != NULL && uprv_strcmp(lang, srBundle->fLocale)!=0){ |
| 1139 fprintf(stderr,"Warning: The top level tag in the resource and language
specified are not the same. Please check the input.\n"); | 1149 fprintf(stderr,"Warning: The top level tag in the resource and language
specified are not the same. Please check the input.\n"); |
| 1140 } | 1150 } |
| 1141 write_utf8_file(out, UnicodeString(lang)); | 1151 write_utf8_file(out, UnicodeString(lang)); |
| 1142 write_utf8_file(out, UnicodeString(file1)); | 1152 write_utf8_file(out, UnicodeString(file1)); |
| 1143 write_utf8_file(out, UnicodeString(file2)); | 1153 write_utf8_file(out, UnicodeString(file2)); |
| 1144 write_utf8_file(out, UnicodeString(originalFileName)); | 1154 write_utf8_file(out, UnicodeString(originalFileName)); |
| 1145 write_utf8_file(out, UnicodeString(file4)); | 1155 write_utf8_file(out, UnicodeString(file4)); |
| 1146 | 1156 |
| 1147 time(&currTime); | 1157 time(&currTime); |
| 1148 strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&currTime)); | 1158 strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&currTime)); |
| 1149 write_utf8_file(out, UnicodeString(timeBuf)); | 1159 write_utf8_file(out, UnicodeString(timeBuf)); |
| 1150 write_utf8_file(out, UnicodeString("\">\n")); | 1160 write_utf8_file(out, UnicodeString("\">\n")); |
| 1151 | 1161 |
| 1152 tabCount += 1; | 1162 tabCount += 1; |
| 1153 write_tabs(out); | 1163 write_tabs(out); |
| 1154 write_utf8_file(out, headerStart); | 1164 write_utf8_file(out, UnicodeString(headerStart)); |
| 1155 | 1165 |
| 1156 tabCount += 1; | 1166 tabCount += 1; |
| 1157 write_tabs(out); | 1167 write_tabs(out); |
| 1158 | 1168 |
| 1159 write_utf8_file(out, tool_start); | 1169 write_utf8_file(out, UnicodeString(tool_start)); |
| 1160 printAttribute("tool-id", tool_id, (int32_t) uprv_strlen(tool_id)); | 1170 printAttribute("tool-id", tool_id, (int32_t) uprv_strlen(tool_id)); |
| 1161 printAttribute("tool-name", tool_name, (int32_t) uprv_strlen(tool_name)); | 1171 printAttribute("tool-name", tool_name, (int32_t) uprv_strlen(tool_name)); |
| 1162 write_utf8_file(out, UnicodeString("/>\n")); | 1172 write_utf8_file(out, UnicodeString("/>\n")); |
| 1163 | 1173 |
| 1164 tabCount -= 1; | 1174 tabCount -= 1; |
| 1165 write_tabs(out); | 1175 write_tabs(out); |
| 1166 | 1176 |
| 1167 write_utf8_file(out, UnicodeString(headerEnd)); | 1177 write_utf8_file(out, UnicodeString(headerEnd)); |
| 1168 | 1178 |
| 1169 write_tabs(out); | 1179 write_tabs(out); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1191 cleanup_bundle_write_xml: | 1201 cleanup_bundle_write_xml: |
| 1192 uprv_free(originalFileName); | 1202 uprv_free(originalFileName); |
| 1193 uprv_free(lang); | 1203 uprv_free(lang); |
| 1194 if(xmlfileName != NULL) { | 1204 if(xmlfileName != NULL) { |
| 1195 uprv_free(xmlfileName); | 1205 uprv_free(xmlfileName); |
| 1196 } | 1206 } |
| 1197 if(outputFileName != NULL){ | 1207 if(outputFileName != NULL){ |
| 1198 uprv_free(outputFileName); | 1208 uprv_free(outputFileName); |
| 1199 } | 1209 } |
| 1200 } | 1210 } |
| OLD | NEW |