Python read ISO 8859-1 (Latin1) encoding

import codecs
f = codecs.open(path, 'r', 'iso-8859-1')
str = f.read()
f.close()

Advertisements

ISO 8859-1 (Latin1) encoding

if you ever meet 2 byte characters, that

  1. are not UTF8
  2. become rubbish when you translate to UTF8
  3. should be latin character variations such as á, ç, or ö
  4. have high first byte (0xF2), which is the case for the most commmon latin char variations

suspect this encoding. It is quite common. For a list see

http://www.w3schools.com/tags/ref_entities.asp