开发者

Code to convert Unicode to ASCII

开发者 https://www.devze.com 2022-12-12 08:16 出处:网络
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

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

精彩评论

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