• [^] # Re: Le bon bash des familles

    Posté par (site web personnel) . En réponse au journal Python comme premier langage de programmation ?. Évalué à 1. Dernière modification le 23 juillet 2014 à 08:49.

    Par exemple j'aimerais bien retrouver la séparation byte/unicode de Python3 dans le C++ avec un type chaîne correct.

    Tu veux dire std::u32string ?

    Et aussi std::codecvt_utf8 ?

    Pour ma part, j'utilise ce code pour faire la conversion UTF-8 UCS-4

    #include <string>
    #include <codecvt>
    std::string toUTF8(const std::u32string &s)
    {
     std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> cv;
     return cv.to_bytes(s);
    }
    std::u32string toUCS4(const std::string &s)
    {
     std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> cv;
     return cv.from_bytes(s);
    }
    int main(void)
    {
     return 0;
    }

    AI is a mental disorder