C++編碼轉換通用類

來源:互聯網
上載者:User

相關內容:

C++實現char*轉BSTR的5個方法

C++實現BSTR轉char*的2個方法

C++實現ANSI編碼和Unicode編碼互轉

C++實現UTF-8編碼和Unicode編碼互轉

C++編碼轉換通用類,供大家參考。head檔案wide_string.h內容如下:

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/*
 * 寬字元串
 */
class WideString
{

    //wchar_t;
    wchar_t* ws;
    //初始化
    void init(char*, unsigned int);

    public:
        /*
         * 建構函式,將傳入的字串轉換成wchar_t;
         */
        WideString(char*);
        /*
         * 建構函式,將傳入的字串轉換成wchar_t;
         */
        WideString(char*, unsigned int);
        /*
         * 解構函式,釋放wchar_t;
         */
        ~WideString();
        /*
         * 轉換成UTF-8字串
         */
        void toUTF8String(char*);
        /*
         * 擷取UTF-8字串長度
         */
        unsigned int getUTF8StringLength();
        /*
         * 轉換成預設編碼字串
         */
        void toDefaultString(char*);
        /*
         * 擷取預設編碼字串長度
         */
        unsigned int getDefaultStringLength();
        /*
         * 轉換成MultiBytes字串
         */
        void toMultiBytesString(char*, unsigned int);
        /*
         * 擷取MultiBytes字串長度
         */
        unsigned int getMultiBytesStringLength(unsigned int);
};

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.