safe.utilities.unicode module

InaSAFE Disaster risk assessment tool by AusAid -Unicode Utilities.

The module provides utilities function to convert between unicode and byte string for Python 2.x. When we move to Python 3, this module and its usage should be removed as string in Python 3 is already stored in unicode.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

safe.utilities.unicode.get_string(input_text, encoding='utf-8')[source]

Get byte string representation of an object.

Parameters:
  • input_text (unicode, str, float, int) – The input text.
  • encoding (str) – The encoding used to do the conversion, default to utf-8.
Returns:

Byte string representation of the input.

Return type:

str

safe.utilities.unicode.get_unicode(input_text, encoding='utf-8')[source]

Get the unicode representation of an object.

Parameters:
  • input_text (unicode, str, float, int) – The input text.
  • encoding (str) – The encoding used to do the conversion, default to utf-8.
Returns:

Unicode representation of the input.

Return type:

unicode