Ruby 1.9 introduced string encodings to improve support for internationalization, but SWIG creates Ruby strings with their encodings set to ASCII-8BIT, which is an alias for BINARY. It would be nice if SWIG created Ruby strings with a more text-friendly encoding, such as UTF-8 (http://www.utf8everywhere.org/), or gave the user some way to select their preferred string encoding.
The following code and its resulting script output illustrates the problem with the default string encoding used with Ruby 1.9. Note that because ASCII-8BIT is a binary encoding, the #to_yaml call outputs the string returned by foobar() as base64 binary data instead of human-readable text.
--- !binary |-