encode('utf- ' ' \xc \ \xc \xa clen( encode('utf- ') bytes when encoded per latin- bytes when encoded per utf- technically speakingyou can also build unicode strings piecemeal using chr instead of unicode or hex escapesbut this might become tedious for large stringss 'achr( xc 'bchr( xe 'cs 'aabecsome other encodings may use very different byte formatsthough the cp ebcdic encodingfor exampledoesn' even encode ascii the same way as the encodings we've been using so farsince python encodes and decodes for uswe only generally need to care about this when providing encoding names for data sourcess 'aabecs encode('cp ' '\xc \xc \xc encode('cp ' ' \ eb\ acs 'spams encode('latin- ' 'spams encode('utf- ' 'spams encode('cp ' '\xa \ \ \ encode('cp ' 'spamtwo other western european encodings bytes eachdifferent encoded values ascii text is the same in most but not in cp ibm ebcdicthe same holds true for the utf- and utf- encodingswhich use fixed and byte-per-character schemes with same-sized headers--non-ascii encodes differentlyand ascii is not byte per characters ' \ \ cs encode('utf- ' '\xff\xfea\ \xc \ \ \xe \ \ 'spams encode('utf- ' '\xff\xfes\ \ \ \ encode('utf- ' '\xff\xfe\ \ \ \ \ \ \ \ \ \ \ \ \ \ unicode and byte strings