willie <[EMAIL PROTECTED]> writes:
> >>> ustr = buf.decode('UTF-8')
> >>> type(ustr)
>
> Is it a "unicode object that contains a UTF-8 encoded
> string object?"
No, it's just unicode, which is a string over a certain character set.
UTF-8 is a way to encode unicode strings as byte strings.
You
>willie wrote:
>>
>> Thanks for the thorough explanation. One last question
>> about terminology then I'll go away :)
>> What is the proper way to describe "ustr" below?
>> >>> ustr = buf.decode('UTF-8')
>> >>> type(ustr)
>>
>> Is it a "unicode object that contains a UTF-8 encoded
>>
willie wrote:
>
> Thanks for the thorough explanation. One last question
> about terminology then I'll go away :)
> What is the proper way to describe "ustr" below?
>
> >>> ustr = buf.decode('UTF-8')
> >>> type(ustr)
>
>
>
> Is it a "unicode object that contains a UTF-8 encoded
> string object?
At Wednesday 20/9/2006 19:53, willie wrote:
What is the proper way to describe "ustr" below?
>>> ustr = buf.decode('UTF-8')
>>> type(ustr)
Is it a "unicode object that contains a UTF-8 encoded
string object?"
ustr is an unicode object. Period. An unicode object contains
characters (not
MonkeeSage wrote:
> OK, so the devil always loses. ;P
>
> Regards,
> Jordan
Huh? The devil always loses? *turns TV on, watches the news, turns TV
off* Nope, buddy. Quite the contrary.
--
http://mail.python.org/mailman/listinfo/python-list
Martin v. Löwis:
>willie schrieb:
>
>> Thank you for your patience and for educating me.
>> (Though I still have a long way to go before enlightenment)
>> I thought Python might have a small weakness in
>> lacking an efficient way to get the number of bytes
>> in a "UTF-8 encoded Python str
willie schrieb:
> Thank you for your patience and for educating me.
> (Though I still have a long way to go before enlightenment)
> I thought Python might have a small weakness in
> lacking an efficient way to get the number of bytes
> in a "UTF-8 encoded Python string object" (proper?),
> but I've
John Machin:
>Good luck!
Thank you for your patience and for educating me.
(Though I still have a long way to go before enlightenment)
I thought Python might have a small weakness in
lacking an efficient way to get the number of bytes
in a "UTF-8 encoded Python string object" (proper?),
but I'v
willie wrote:
> John Machin:
>
> >You are confusing the hell out of yourself. You say that your web app
> >deals only with UTF-8 strings. Where do you get "the unicode string"
> >from??? If name is a utf-8 string, as your comment says, then len(name)
> >is all you need!!!
>
>
> # I'll go ah
willie wrote:
> John Machin:
>
> >You are confusing the hell out of yourself. You say that your web app
> >deals only with UTF-8 strings. Where do you get "the unicode string"
> >from??? If name is a utf-8 string, as your comment says, then len(name)
> >is all you need!!!
>
>
> # I'll go ahead
John Machin:
>You are confusing the hell out of yourself. You say that your web app
>deals only with UTF-8 strings. Where do you get "the unicode string"
>from??? If name is a utf-8 string, as your comment says, then len(name)
>is all you need!!!
# I'll go ahead and concede defeat since you
willie wrote:
> >willie wrote:
> >> Marc 'BlackJack' Rintsch:
> >>
> >> >In <[EMAIL PROTECTED]>, willie
> wrote:
> >> >> # What's the correct way to get the
> >> >> # byte count of a unicode (UTF-8) string?
> >> >> # I couldn't find a builtin method
> >> >> # and the following is memory
OK, so the devil always loses. ;P
Regards,
Jordan
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth <[EMAIL PROTECTED]> writes:
> I guess you could invent something like inserting a string into a database
> which has fixed size fields, silently truncates fields which are too long
> and stores the strings internally in utf-8 but only accepts ucs-2 in its
> interface. Pretty far fet
"MonkeeSage" <[EMAIL PROTECTED]> wrote:
> John Machin wrote:
>> The answer is, "You can't", and the rationale would have to be that
>> nobody thought of a use case for counting the length of the UTF-8 form
>> but not creating the UTF-8 form. What is your use case?
>
> Playing DA here, what if yo
MonkeeSage schrieb:
> John Machin wrote:
>> The answer is, "You can't", and the rationale would have to be that
>> nobody thought of a use case for counting the length of the UTF-8 form
>> but not creating the UTF-8 form. What is your use case?
>
> Playing DA here, what if you need to send the by
John Machin wrote:
> The answer is, "You can't", and the rationale would have to be that
> nobody thought of a use case for counting the length of the UTF-8 form
> but not creating the UTF-8 form. What is your use case?
Playing DA here, what if you need to send the byte-count on a server
via a he
>willie wrote:
>> Marc 'BlackJack' Rintsch:
>>
>> >In <[EMAIL PROTECTED]>, willie
wrote:
>> >> # What's the correct way to get the
>> >> # byte count of a unicode (UTF-8) string?
>> >> # I couldn't find a builtin method
>> >> # and the following is memory inefficient.
>> >> ustr =
willie wrote:
> Marc 'BlackJack' Rintsch:
>
> >In <[EMAIL PROTECTED]>, willie wrote:
> >> # What's the correct way to get the
> >> # byte count of a unicode (UTF-8) string?
> >> # I couldn't find a builtin method
> >> # and the following is memory inefficient.
>
> >> ustr = "example\xC2\x9D"
Marc 'BlackJack' Rintsch:
>In <[EMAIL PROTECTED]>, willie wrote:
>> # What's the correct way to get the
>> # byte count of a unicode (UTF-8) string?
>> # I couldn't find a builtin method
>> # and the following is memory inefficient.
>> ustr = "example\xC2\x9D".decode('UTF-8')
>> num_chars
In <[EMAIL PROTECTED]>, willie wrote:
> # What's the correct way to get the
> # byte count of a unicode (UTF-8) string?
> # I couldn't find a builtin method
> # and the following is memory inefficient.
>
> ustr = "example\xC2\x9D".decode('UTF-8')
>
> num_chars = len(ustr)# 8
>
> buf = ustr.
willie wrote:
> # What's the correct way to get the
> # byte count of a unicode (UTF-8) string?
> # I couldn't find a builtin method
> # and the following is memory inefficient.
>
> ustr = "example\xC2\x9D".decode('UTF-8')
>
> num_chars = len(ustr)# 8
>
> buf = ustr.encode('UTF-8')
>
> num_byte
# What's the correct way to get the
# byte count of a unicode (UTF-8) string?
# I couldn't find a builtin method
# and the following is memory inefficient.
ustr = "example\xC2\x9D".decode('UTF-8')
num_chars = len(ustr)# 8
buf = ustr.encode('UTF-8')
num_bytes = len(buf) # 9
# Thanks.
23 matches
Mail list logo