How can I decode HTML entities in C++?

前端 未结 1 1673
南旧
南旧 2020-12-17 18:25

How can I decode HTML entities in C++?

For example:

HTML: "Music" & "video"

Decoded: "Music" &

相关标签:
1条回答
  • 2020-12-17 19:18

    If you're comfortable with using C-strings, you might be interested in my answer to a similar question.


    There's no need to compile the code as C++: compile entities.c as -std=c99 and link the object file with your C++ code, eg if you have the follwing example program foo.cpp

    #include <iostream>
    
    extern "C" size_t decode_html_entities_utf8(char *dest, const char *src);
    
    int main()
    {
        char line[100];
        std::cout << "Enter encoded line: ";
        std::cin.getline(line, sizeof line);
        decode_html_entities_utf8(line, 0);
        std::cout << line;
        return 0;
    }
    

    use

    g++ -o foo foo.cpp entities.o
    
    0 讨论(0)
提交回复
热议问题