Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何打印unicode字符的位表示形式_C++_Windows_Unicode_Utf 8 - Fatal编程技术网

C++ 如何打印unicode字符的位表示形式

C++ 如何打印unicode字符的位表示形式,c++,windows,unicode,utf-8,C++,Windows,Unicode,Utf 8,我尝试获得unicode字符的二进制utf-8表示,如图所示: 但这只适用于两个问题: 反向位模式(二进制从左到右读取位7到0) 符号分机 std::string contobin(std::string str) { std::字符串结果; 对于(int i=0;i两个问题: 反向位模式(二进制从左到右读取位7到0) 符号分机 std::string contobin(std::string str) { std::字符串结果; 对于(int i=0;i两个问题: 反向位模式(二进制从左

我尝试获得unicode字符的二进制utf-8表示,如图所示:

但这只适用于两个问题:

  • 反向位模式(二进制从左到右读取位7到0)

  • 符号分机

  • std::string contobin(std::string str)
    {
    std::字符串结果;
    对于(int i=0;i两个问题:

  • 反向位模式(二进制从左到右读取位7到0)

  • 符号分机

  • std::string contobin(std::string str)
    {
    std::字符串结果;
    对于(int i=0;i两个问题:

  • 反向位模式(二进制从左到右读取位7到0)

  • 符号分机

  • std::string contobin(std::string str)
    {
    std::字符串结果;
    对于(int i=0;i两个问题:

  • 反向位模式(二进制从左到右读取位7到0)

  • 符号分机

  • std::string contobin(std::string str)
    {
    std::字符串结果;
    
    对于(int i=0;i而不是自己转换为二进制,您可以考虑使用<代码> STD::BITSET ,如下所示:

    #include <bitset>
    
    std::string contoutf8(std::wstring str)
    {    
        int utf8_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(),
                        str.length(), nullptr, 0, nullptr, nullptr);
        std::string utf8_str(utf8_size, '\0');
        WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), 
                        &utf8_str[0], utf8_size, nullptr, nullptr);
        return utf8_str;
    }
    
    int main()
    {
        std::wstring str  = L"\u20AC";
        std::string utf8 = contoutf8(str);
    
        std::copy(utf8.begin(), utf8.end(), std::ostream_iterator<std::bitset<8>>(std::cout, "\t"));
    }
    
    #包括
    std::string contout08(std::wstring str)
    {    
    int-utf8\u size=WideCharToMultiByte(CP\u-utf8,0,str.c\u str(),
    str.length(),nullptr,0,nullptr,nullptr);
    字符串utf8_str(utf8_大小,'\0');
    宽图表多字节(CP_UTF8,0,str.c_str(),str.length(),
    &utf8_str[0],utf8_size,nullptr,nullptr);
    返回utf8_str;
    }
    int main()
    {
    std::wstring str=L“\u20AC”;
    std::string utf8=contoutf8(str);
    std::copy(utf8.begin()、utf8.end()、std::ostream\u迭代器(std::cout,“\t”);
    }
    
    > p>而不是自己转换为二进制,您可以考虑使用<代码> STD::BITSET ,如下所述:

    #include <bitset>
    
    std::string contoutf8(std::wstring str)
    {    
        int utf8_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(),
                        str.length(), nullptr, 0, nullptr, nullptr);
        std::string utf8_str(utf8_size, '\0');
        WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), 
                        &utf8_str[0], utf8_size, nullptr, nullptr);
        return utf8_str;
    }
    
    int main()
    {
        std::wstring str  = L"\u20AC";
        std::string utf8 = contoutf8(str);
    
        std::copy(utf8.begin(), utf8.end(), std::ostream_iterator<std::bitset<8>>(std::cout, "\t"));
    }
    
    #包括
    std::string contout08(std::wstring str)
    {    
    int-utf8\u size=WideCharToMultiByte(CP\u-utf8,0,str.c\u str(),
    str.length(),nullptr,0,nullptr,nullptr);
    字符串utf8_str(utf8_大小,'\0');
    宽图表多字节(CP_UTF8,0,str.c_str(),str.length(),
    &utf8_str[0],utf8_size,nullptr,nullptr);
    返回utf8_str;
    }
    int main()
    {
    std::wstring str=L“\u20AC”;
    std::string utf8=contoutf8(str);
    std::copy(utf8.begin()、utf8.end()、std::ostream\u迭代器(std::cout,“\t”);
    }
    
    > p>而不是自己转换为二进制,您可以考虑使用<代码> STD::BITSET ,如下所述:

    #include <bitset>
    
    std::string contoutf8(std::wstring str)
    {    
        int utf8_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(),
                        str.length(), nullptr, 0, nullptr, nullptr);
        std::string utf8_str(utf8_size, '\0');
        WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), 
                        &utf8_str[0], utf8_size, nullptr, nullptr);
        return utf8_str;
    }
    
    int main()
    {
        std::wstring str  = L"\u20AC";
        std::string utf8 = contoutf8(str);
    
        std::copy(utf8.begin(), utf8.end(), std::ostream_iterator<std::bitset<8>>(std::cout, "\t"));
    }
    
    #包括
    std::string contout08(std::wstring str)
    {    
    int-utf8\u size=WideCharToMultiByte(CP\u-utf8,0,str.c\u str(),
    str.length(),nullptr,0,nullptr,nullptr);
    字符串utf8_str(utf8_大小,'\0');
    宽图表多字节(CP_UTF8,0,str.c_str(),str.length(),
    &utf8_str[0],utf8_size,nullptr,nullptr);
    返回utf8_str;
    }
    int main()
    {
    std::wstring str=L“\u20AC”;
    std::string utf8=contoutf8(str);
    std::copy(utf8.begin()、utf8.end()、std::ostream\u迭代器(std::cout,“\t”);
    }
    
    > p>而不是自己转换为二进制,您可以考虑使用<代码> STD::BITSET ,如下所述:

    #include <bitset>
    
    std::string contoutf8(std::wstring str)
    {    
        int utf8_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(),
                        str.length(), nullptr, 0, nullptr, nullptr);
        std::string utf8_str(utf8_size, '\0');
        WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), 
                        &utf8_str[0], utf8_size, nullptr, nullptr);
        return utf8_str;
    }
    
    int main()
    {
        std::wstring str  = L"\u20AC";
        std::string utf8 = contoutf8(str);
    
        std::copy(utf8.begin(), utf8.end(), std::ostream_iterator<std::bitset<8>>(std::cout, "\t"));
    }
    
    #包括
    std::string contout08(std::wstring str)
    {    
    int-utf8\u size=WideCharToMultiByte(CP\u-utf8,0,str.c\u str(),
    str.length(),nullptr,0,nullptr,nullptr);
    字符串utf8_str(utf8_大小,'\0');
    宽图表多字节(CP_UTF8,0,str.c_str(),str.length(),
    &utf8_str[0],utf8_size,nullptr,nullptr);
    返回utf8_str;
    }
    int main()
    {
    std::wstring str=L“\u20AC”;
    std::string utf8=contoutf8(str);
    std::copy(utf8.begin()、utf8.end()、std::ostream\u迭代器(std::cout,“\t”);
    }
    
    那么你得到了什么?那么你得到了什么?那么你得到了什么?那么你得到了什么?符号扩展并不重要,因为只观察到最低的8位。符号扩展不重要,因为只观察到最低的8位。符号扩展不重要,因为只观察到最低的8位。符号扩展不重要这并不重要,因为只观察到最低的8位。