Hello there, i have this problem when i try to combine a variable file name that is in languages other than English with a path, like this :

path = 'C:\\Files\\'

path+=UnicodeName+'.txt'

it gives the following error :

UnicodeDecodeError: 'ascii' codec can't decode byte 0xda in position 7: ordinal not in range(128).

Thanks for your help in advance.

I'm running python 2.6, and it does not raise an exception, instead, it converts path to unicode:

>>> path = 'C:\\Files\\'
>>> UnicodeName = u"\u2344"
>>> path+=UnicodeName+'.txt'
>>> path
u'C:\\Files\\\u2344.txt'
>>> print path
C:\Files\⍄.txt

There must be something missing in your example. Can you post console output ?

Thank you, problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.