Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15083

Re: Unicode literals and byte string interpretation.

Subject Re: Unicode literals and byte string interpretation.
From David Riley <fraveydank@gmail.com>
Date 2011-10-27 23:37 -0400
References <8de0e9b7-aaac-44a4-8a07-9c1a20bfc3eb@s7g2000yqa.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2272.1319773026.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Oct 27, 2011, at 11:05 PM, Fletcher Johnson wrote:

> If I create a new Unicode object u'\x82\xb1\x82\xea\x82\xcd' how does
> this creation process interpret the bytes in the byte string? Does it
> assume the string represents a utf-16 encoding, at utf-8 encoding,
> etc...?
> 
> For reference the string is これは in the 'shift-jis' encoding.

Try it and see!  One test case is worth a thousand words.  And Python has an interactive interpreter. :-)


- Dave

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unicode literals and byte string interpretation. Fletcher Johnson <flt.johnson@gmail.com> - 2011-10-27 20:05 -0700
  Re: Unicode literals and byte string interpretation. David Riley <fraveydank@gmail.com> - 2011-10-27 23:37 -0400
  Re: Unicode literals and byte string interpretation. Chris Angelico <rosuav@gmail.com> - 2011-10-28 14:38 +1100
  Re: Unicode literals and byte string interpretation. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-28 07:06 +0000
    Re: Unicode literals and byte string interpretation. Fletcher Johnson <flt.johnson@gmail.com> - 2011-10-31 21:01 -0700

csiph-web