Template ToString function that works with different character encoding
<p>I've written an INI class that loads/saves/creates an INI data format, however right now it only works with ascii characters, and I would like to expand it to work with any type of character encoding, so besides char, wchar_t.  To do this, I have to setup various string functions for doing the parsing; I have some setup, however I need to rewrite them to work with any type of basic_string.  </p>

<p>So, as to my question, I want a ToString function that will work with any type of character encoding, how do I do this?</p>

<p>I have the following two functions:</p>

<pre><code>template &lt;typename T&gt;
static string toStr(const T&amp; val)
{
    stringstream out;
    out &lt;&lt; val;
    return out.str();
}

template &lt;typename T&gt;
static wstring toWStr(const T&amp; val)
{
    wstringstream out;
    out &lt;&lt; val;
    return out.str();
}
</code></pre>
