I have been trying to convert the ISO-8859 charset to utf-8 with the code obtained from : Convert ISO-8859-1 strings to UTF-8 in C/C++ Here is my code :
#include <iostream>
#include <string>
using namespace std;
int main(int argc,char* argv[])
{
    string fileName ="ħëlö";
    int len= fileName.length();
    char* in = new char[len+1];
    char* out = new char[2*(len+1)];
    memset(in,'\0',len+1);
    memset(out,'\0',len+1);
    memcpy(in,fileName.c_str(),2*(len+1));
    while( *in )
    {
            cout << " ::: " << in ;
            if( *in <128 )
            {
                    *out++ = *in++;
            }
            else
            {
                    *out++ = 0xc2+(*in>0xbf);
                    *out++ = (*in++&0x3f)+0x80;
            }
    }
    cout << "\n\n out ::: " << out << "\n";
    *out = '\0';
}
But the output is
::: ħëlö ::: ?ëlö ::: ëlö ::: ?lö ::: lö ::: ö ::: ?
 out :::   
The output 'out' should be a utf-8 string and it is not. I'm getting this in Mac OS X..
What am i doing wrong here ..?