STIXProject/python-stix — pull request #233 by bworrell (2014-11-22 20:02:44+00:00)
Title: Unicode

Addresses some of the unicode issues in python-stix:

* Resolves #220: `quote_xml()` and `quote_attrib` binding methods handle integer/boolean types correctly now.
* Resolves #194: Fixed XML encoding issues in `StructuredTextType` to correctly escape XML-reserved characters and handle unicode characters.
* Resolves #230: Updated docstrings to mention character encoded output.

The following changes were made:

* The `stix.bindings.quote_xml()` and `stix.bindings.quote_attrib()` methods were refactored to convert all input into `ExternalEncoding` encoded strings. All calls to `quote_attrib()` and `quote_xml()` were updated to align with new return value (so as to eliminate double calls to `encode()`).
* Added a non-exhaustive `encoding_tests.py` unit test suite for checking behavior of parsing, serializing, and round-tripping unicode in python-stix. Also tests how non-string and non-unicode values are handled by `quote_xml()` and `quote_attrib()` methods.
* Updated docstrings for `Entity.to_xml()` to document current behavior, arguments, and return values. This does not address #224 as it was out of scope for the `unicode` branch. As such, the docstrings will need to be updated once #224 is handled.

@gtback, can you take a look at this? I looked at python-cybox for implementation guidance, but deviated in some places. I believe the behaviors are the same between the libraries however.