osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Putting Unicode characters in JSON


On Fri, 23 Mar 2018 12:05:34 +1100, Chris Angelico wrote:

> Latin-1 is not "arbitrary bytes". It is a very specific encoding that
> cannot decode every possible byte value.

Yes it can.

py> blob = bytes(range(256))
py> len(blob)
256
py> blob[45:55]
b'-./0123456'
py> s = blob.decode('latin1')
py> len(s)
256
py> s[45:55]
'-./0123456'



-- 
Steve