StringIO + unicode

L

Laszlo Nagy

Is there a standard "in-memory file" interface for reading/writting
unicode stings? Something like StringIO.

E.g. this would be possible:

- create UnicodeStringIO
- write unicode strings into it
- wite data (binary) string of UnicodeStringIO into a file ('wb' mode)

and then later:

- read the same file with codecs.open(filename,"r",encoding="utf-8")

Maybe there is no standard class for this and I have to implement it
myself. (?)

Thanks,

Laszlo
 
D

Diez B. Roggisch

Laszlo said:
Is there a standard "in-memory file" interface for reading/writting
unicode stings? Something like StringIO.

E.g. this would be possible:

- create UnicodeStringIO
- write unicode strings into it
- wite data (binary) string of UnicodeStringIO into a file ('wb' mode)

and then later:

- read the same file with codecs.open(filename,"r",encoding="utf-8")

Maybe there is no standard class for this and I have to implement it
myself. (?)

Never tried it, but can't you just combine StringIO + codecs-module, the
latter offers a wrapping-service for streams.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,851
Latest member
CliftonCor

Latest Threads

Top