- DEBUG("Done composing XML document. Now converting to UTF-16 and "
- "writing it to the output file.");
-
- content = xmlBufferContent(buf);
- len = xmlBufferLength(buf);
-
- DEBUG("XML UTF-8 length = %zu", len);
-
- utf16_str = utf8_to_utf16(content, len, &utf16_len);
- if (!utf16_str) {
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_text_writer;
- }
-
- DEBUG("XML UTF-16 length = %zu", utf16_len);
-
- if ((putc(0xff, out)) == EOF || (putc(0xfe, out) == EOF) ||
- ((bytes_written = fwrite(utf16_str, 1, utf16_len, out))
- != utf16_len)) {
- ERROR_WITH_ERRNO("Error writing XML data");
- ret = WIMLIB_ERR_WRITE;
- goto out_free_utf16_str;
- }
-
- DEBUG("Cleaning up.");