UTF-8 and Local Resource

Hello Folks,



I am currently reading CSV data from the Resource directory. The file contains UTF-8 strings (accents and all that good stuff).

To read it, I use



<br />
handle = StringIO.StringIO(Resource.Load(PLUGIN_DATA, binary=False))<br />
data = csv.reader(handle)<br />




Unfortunately, Resource.Load() uses a plain read() which results in poorly displayed data as the UTF-8 characters are not handled.

Do you guys know a way around this?

TIA
JP

Have you tried passing binary=True into Resource.Load(), and decoding the string yourself? That’ll instruct the underlying Python file handling code to pass the data back unchanged.

Thanks! Worked nicely.

Great! Glad it worked :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.