i have a problem,list is my code
void test(void)
{
workbook swb;
xf_t sxf1 = swb.xformat();
worksheet ssh;
ssh = swb.sheet("sheet_1");
string snamelabel = "中文";
ssh->label(1,2,snamelabel,sxf1);
swb.Dump("workbook.xls");
}
create the workbook.xls exactly, but the cell value is "iconv failed!". it is convert error, so what should i do,this is a matter of great urgency for me,who can help me ,thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So you create an ascii string (string type) and then pass it to xlslib, which looks at all the characters and sees its UTF8. It wants to try and help, but it doesn't know the encoding of the characters, so it guesses UTF-8, but for some reason that fails.
If at all possible pass the strings to xlslib as "wstrings" (wide strings), or even string16type (you'd probably have to set each character in this mode). Look at the headers and you will see the options.
In the workbook header there is some way to set the iconv encoding I recall - don't have time to look for it now - but then you'd have to figure out what your system is doing when you set a "string" to a non-ascii value.
Last edit: David Hoerl 2014-04-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i have a problem,list is my code
void test(void)
{
workbook swb;
xf_t sxf1 = swb.xformat();
worksheet ssh;
ssh = swb.sheet("sheet_1");
string snamelabel = "中文";
ssh->label(1,2,snamelabel,sxf1);
swb.Dump("workbook.xls");
}
create the workbook.xls exactly, but the cell value is "iconv failed!". it is convert error, so what should i do,this is a matter of great urgency for me,who can help me ,thanks!
So you create an ascii string (string type) and then pass it to xlslib, which looks at all the characters and sees its UTF8. It wants to try and help, but it doesn't know the encoding of the characters, so it guesses UTF-8, but for some reason that fails.
If at all possible pass the strings to xlslib as "wstrings" (wide strings), or even string16type (you'd probably have to set each character in this mode). Look at the headers and you will see the options.
In the workbook header there is some way to set the iconv encoding I recall - don't have time to look for it now - but then you'd have to figure out what your system is doing when you set a "string" to a non-ascii value.
Last edit: David Hoerl 2014-04-28
I have write a func to code and it works.
Add this func to xlslib/src/sheetrec.cpp file and recompile the xlslib src code.
cell_t worksheet::label(int code, unsigned16_t row, unsigned16_t col,
const char strlabel, xf_t pxformat)
{
enum { UTF8, GBK };
unsigned16_t u16;
u16string str16;
label_t lbl;
wstring::const_iterator wbegin, wend;
size_t len;