New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicode values in validation source fails #135

Closed
mirzaasif opened this Issue Jun 18, 2014 · 4 comments

Comments

2 participants
@mirzaasif

If we put unicode values in validation source it fails with following error.

UnicodeEncodeError at /inventoryx/export/Product/
'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)

Here is validation data

{'source': [u'None', u'\u0997\u09a4\u09ac\u09be\u09b0\u09c7\u09b0'], 'validate': 'list'}

Here is some debug information:

/python2.7/site-packages/xlsxwriter/worksheet.py in data_validation

Line 1758-  formula = ','.join([str(item) for item in options['value']]) 
options 
{'criteria': 'between',
 'error_type': 0,
 'maximum': None,
 'source': [u'None', u'\u0997\u09a4\u09ac\u09be\u09b0\u09c7\u09b0'],
 'validate': 'list',
 'value': [u'None', u'\u0997\u09a4\u09ac\u09be\u09b0\u09c7\u09b0']}

It should be able to handle unicode values.

mirzaasif added a commit to mirzaasif/XlsxWriter that referenced this issue Jun 18, 2014

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jun 18, 2014

Owner

Hi,

Could you post a small working example that demonstrates the issue.

Thanks,

John

Owner

jmcnamara commented Jun 18, 2014

Hi,

Could you post a small working example that demonstrates the issue.

Thanks,

John

@jmcnamara jmcnamara self-assigned this Jun 18, 2014

@jmcnamara jmcnamara added the bug label Jun 18, 2014

@mirzaasif

This comment has been minimized.

Show comment
Hide comment
@mirzaasif

mirzaasif Jun 18, 2014

Hi John,

Here is sample code which will produce this issue:

# -*- coding: utf-8 -*-
import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write('A1', 'Hello world')
worksheet.data_validation('A2', {'validate': 'list', 'source': [u"A", u"Это фраза на русском!"]})
workbook.close()

Best,
Mirza

Hi John,

Here is sample code which will produce this issue:

# -*- coding: utf-8 -*-
import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write('A1', 'Hello world')
worksheet.data_validation('A2', {'validate': 'list', 'source': [u"A", u"Это фраза на русском!"]})
workbook.close()

Best,
Mirza

mirzaasif added a commit to mirzaasif/XlsxWriter that referenced this issue Jun 18, 2014

jmcnamara added a commit that referenced this issue Jun 19, 2014

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jun 19, 2014

Owner

Hi Mirza,

I've pushed a fix to master. You can try it when you get a chance.

John

Owner

jmcnamara commented Jun 19, 2014

Hi Mirza,

I've pushed a fix to master. You can try it when you get a chance.

John

@mirzaasif

This comment has been minimized.

Show comment
Hide comment
@mirzaasif

mirzaasif Jun 20, 2014

It seems to work. Thanks for this quick fix :).

It seems to work. Thanks for this quick fix :).

@mirzaasif mirzaasif closed this Jun 20, 2014

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