开发者

Code to convert Unicode to ASCII

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜