Read view encoding and transform it for use with python. This method reads `origin_encoding` used by ConvertToUTF8 plugin and goes on with ST's encoding setting if required. The encoding is transformed to work with python's `codecs` module. Returns: stri
(self)
| 142 | return True |
| 143 | |
| 144 | def python_friendly_encoding(self): |
| 145 | """Read view encoding and transform it for use with python. |
| 146 | |
| 147 | This method reads `origin_encoding` used by ConvertToUTF8 plugin and |
| 148 | goes on with ST's encoding setting if required. The encoding is |
| 149 | transformed to work with python's `codecs` module. |
| 150 | |
| 151 | Returns: |
| 152 | string: python compatible view encoding |
| 153 | """ |
| 154 | encoding = self.view.settings().get('origin_encoding') |
| 155 | if not encoding: |
| 156 | encoding = self.view.encoding() |
| 157 | if encoding == 'Undefined': |
| 158 | encoding = self.view.settings().get('default_encoding', '') |
| 159 | return ENCODING_MAP.get(encoding, 'utf-8') |
| 160 | return encoding.replace(' ', '') |
no test coverage detected