"Content is Unreadable" error when strings contain control characters #42

Closed
sw1020 opened this Issue Dec 16, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@sw1020

sw1020 commented Dec 16, 2015

Issue with Content is Unreadable. Open and Repair

I am using libxlsxwriter to make a node addon.

I found : when I write the utf-8 string with some special characters , it will cause the problem
for exzample: <Buffer e5 9b be 14 e5 9b be>

pls help

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 16, 2015

Owner

The "Content is Unreadable. Open and Repair" error is Excel's standard warning for any validation error in the XML used for the components of the XLSX file. It doesn't really help to identify the problem.

You will need to submit a small working example that demonstrates the issue. See the Bug Reporting Guidelines.

Note, libxlsxwriter does work with UTF-8. There is an example in the docs/repo and there are several test cases that test it.

John

Owner

jmcnamara commented Dec 16, 2015

The "Content is Unreadable. Open and Repair" error is Excel's standard warning for any validation error in the XML used for the components of the XLSX file. It doesn't really help to identify the problem.

You will need to submit a small working example that demonstrates the issue. See the Bug Reporting Guidelines.

Note, libxlsxwriter does work with UTF-8. There is an example in the docs/repo and there are several test cases that test it.

John

@jmcnamara jmcnamara added the question label Dec 16, 2015

@sw1020

This comment has been minimized.

Show comment
Hide comment
@sw1020

sw1020 Dec 16, 2015

sorry
the utf-8 string example (in hex): e5 9b be 14 e5 9b be
if i replace 0x14 to 0x20 ,it will work fine

sw1020 commented Dec 16, 2015

sorry
the utf-8 string example (in hex): e5 9b be 14 e5 9b be
if i replace 0x14 to 0x20 ,it will work fine

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 16, 2015

Owner

The non-unicode character 0x14 is a control character. These aren't currently supported in libxlsxwriter.

I'll fix that in a later version but for now make sure that your strings don't contain control characters.

Owner

jmcnamara commented Dec 16, 2015

The non-unicode character 0x14 is a control character. These aren't currently supported in libxlsxwriter.

I'll fix that in a later version but for now make sure that your strings don't contain control characters.

@jmcnamara jmcnamara changed the title from Content is Unreadable. Open and Repair to "Content is Unreadable" error when strings contain control characters Dec 16, 2015

@jmcnamara jmcnamara added bug and removed question labels Dec 16, 2015

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 16, 2015

Owner

Here is an example program that demonstrates the issue:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = new_workbook("gh42_1.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    char string[] = {0xe5, 0x9b, 0xbe, 0x14, 0xe5, 0x9b, 0xbe, 0x00};

    worksheet_write_string(worksheet, 0, 0, string, NULL);

    workbook_close(workbook);

    return 0;
}

And here is a working example with the control character replaced with a space:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = new_workbook("gh42_2.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    char string[] = {0xe5, 0x9b, 0xbe, 0x20, 0xe5, 0x9b, 0xbe, 0x00};

    worksheet_write_string(worksheet, 0, 0, string, NULL);

    workbook_close(workbook);

    return 0;
}
Owner

jmcnamara commented Dec 16, 2015

Here is an example program that demonstrates the issue:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = new_workbook("gh42_1.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    char string[] = {0xe5, 0x9b, 0xbe, 0x14, 0xe5, 0x9b, 0xbe, 0x00};

    worksheet_write_string(worksheet, 0, 0, string, NULL);

    workbook_close(workbook);

    return 0;
}

And here is a working example with the control character replaced with a space:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = new_workbook("gh42_2.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    char string[] = {0xe5, 0x9b, 0xbe, 0x20, 0xe5, 0x9b, 0xbe, 0x00};

    worksheet_write_string(worksheet, 0, 0, string, NULL);

    workbook_close(workbook);

    return 0;
}

jmcnamara added a commit that referenced this issue Dec 20, 2015

jmcnamara added a commit that referenced this issue Dec 20, 2015

jmcnamara added a commit that referenced this issue Dec 21, 2015

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 21, 2015

Owner

Fixed in version 0.2.7 and the master HEAD on Github.

Thanks.

Owner

jmcnamara commented Dec 21, 2015

Fixed in version 0.2.7 and the master HEAD on Github.

Thanks.

@jmcnamara jmcnamara closed this Dec 21, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment