| Conditions | 3 |
| Total Lines | 11 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 32 | def encode_string(string): |
||
| 33 | """Encodes a unicode instance to utf-8. If a str is passed it will |
||
| 34 | simply be returned |
||
| 35 | |||
| 36 | :param string: str or unicode to encode |
||
| 37 | :returns : encoded output as str |
||
| 38 | """ |
||
| 39 | if six.PY2: |
||
| 40 | if isinstance(string, six.text_type): |
||
| 41 | return string.encode('utf-8') |
||
| 42 | return string |
||
| 43 | |||
| 57 |