I am looking for code for convert unicode to 7bit ASCII.开发者_Go百科 Any suggestions?
If encoded with utf-8, it is the same for both ascii and unicode as ascii is a subset of unicode. See the example in RFC 2044
A simple example below:
try
{
System.IO.TextWriter writeFile = new StreamWriter("c:\\textwriter.txt",false,Encoding.UTF7);
writeFile.WriteLine("example text here");
writeFile.Flush();
writeFile.Close();
writeFile = null;
}
catch (IOException ex)
{
MessageBox.Show(ex.ToString());
}
I'd recommend to adapt the code from glib C function g_str_to_ascii()
to C++:
Link to g_str_to_ascii()
code
精彩评论