Re: how to get size of unicode string/string in bytes ?

2006-08-02 Thread Walter Dörwald
Diez B. Roggisch wrote: So then the easiest thing to do is: take the maximum length of a unicode string you could possibly want to store, multiply it by 4 and make that the length of the DB field. However, I'm pretty convinced it is a bad idea to store Python unicode strings directly in a

how to get size of unicode string/string in bytes ?

2006-08-01 Thread pattreeya
Hello, how can I get the number of byte of the string in python? with len(string), it doesn't work to get the size of the string in bytes if I have the unicode string but just the length. (it only works fine for ascii/latin1) In data structure, I have to store unicode string for many languages

Re: how to get size of unicode string/string in bytes ?

2006-08-01 Thread pattreeya
e.g. I use utf8 as encoding/decoding, s = ทดสอบ u = s.decode(utf-8) how can I get size of u ? [EMAIL PROTECTED] schrieb: Hello, how can I get the number of byte of the string in python? with len(string), it doesn't work to get the size of the string in bytes if I have the unicode

Re: how to get size of unicode string/string in bytes ?

2006-08-01 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: how can I get the number of byte of the string in python? with len(string), it doesn't work to get the size of the string in bytes if I have the unicode string but just the length. (it only works fine for ascii/latin1) In data structure, I have to store unicode

Re: how to get size of unicode string/string in bytes ?

2006-08-01 Thread Diez B. Roggisch
Stefan Behnel wrote: [EMAIL PROTECTED] wrote: how can I get the number of byte of the string in python? with len(string), it doesn't work to get the size of the string in bytes if I have the unicode string but just the length. (it only works fine for ascii/latin1) In data structure, I have

Re: how to get size of unicode string/string in bytes ?

2006-08-01 Thread pattreeya
I got the answer. What I need was so simple but I was blinded at that moment. Thanks for any suggestion! f = open(test.csv, rb) t1 = f.readline() t2 = t1.decode(iso-8859-9) # test with turkish t2 u'Dur-kalk trafi\u011fi, t\u0131kan\u0131kl\u0131k tehlikesi\n' print t2 Dur-kalk

Re: how to get size of unicode string/string in bytes ?

2006-08-01 Thread Stefan Behnel
Diez B. Roggisch wrote Stefan Behnel wrote: [EMAIL PROTECTED] wrote: how can I get the number of byte of the string in python? with len(string), it doesn't work to get the size of the string in bytes if I have the unicode string but just the length. (it only works fine for ascii/latin1)

Re: how to get size of unicode string/string in bytes ?

2006-08-01 Thread Diez B. Roggisch
So then the easiest thing to do is: take the maximum length of a unicode string you could possibly want to store, multiply it by 4 and make that the length of the DB field. However, I'm pretty convinced it is a bad idea to store Python unicode strings directly in a DB, especially as they