# Fixed some variable substitution issues, unicode help?

**URL:** <https://forum.ansible.com/t/fixed-some-variable-substitution-issues-unicode-help/11755>\
**Category:** Ansible Project\
**Created:** [August 3, 2012, 12:39am UTC](https://forum.ansible.com/t/fixed-some-variable-substitution-issues-unicode-help/11755 "2012-08-03T00:39:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 3, 2012, 12:39am UTC](https://forum.ansible.com/t/fixed-some-variable-substitution-issues-unicode-help/11755/1 "2012-08-03T00:39:47Z")

</div>

I've fixed a few misc variable substation issues reported recently.

In doing so, I had to cast a string as string (not unicode) so I could split it successfully, because the templates come out as unicode objects now (which is probably good).

I have to be careful though as you can't shlex.split a unicode string on some python versions, so when we template the options line, we can't parse it so terribly easily, and I also have to utf-8 encode the module file options.

[http://bugs.python.org/issue6988](http://bugs.python.org/issue6988)

As a result, a unicode parameter to a module "action" line, not a template, is going to get mangled.

I'm going to fiddle with this a bit more, but could use some additional eyes on this, especially from those that are likely to send non-ASCII data. Is this even an issue if  
copy/template aren't affected? Perhaps not.

Anyway, for those that would like to look, additional eyes would be welcome.

--Michael

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 3, 2012, 1:23am UTC](https://forum.ansible.com/t/fixed-some-variable-substitution-issues-unicode-help/11755/2 "2012-08-03T01:23:33Z")

</div>

Progress!

I've figured out how to transfer things cleaner -- don't base64 encode  
the MODULE\_ARGS.

I have to update various modules to mention the Python file contains  
an encoding, which I've already done with command, but it seems to be  
better now.

Still, testing and evolution welcome.

templates still work, the real question is just about unique stuff in  
variables that will be used in "action" lines, which is definitely a  
corner case -- and may not have really worked before anyway, and maybe  
nobody is trying that.

Not base64 encoding and such makes this considerably faster, which is  
also good.

--Michael
