| 989 | else if (strcmp(buf, "yuml") == 0) |
| 990 | { |
| 991 | return (char)255; |
| 992 | } |
| 993 | else |
| 994 | { |
| 995 | return '?'; |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | namespace Poseidon |
| 1000 | { |
| 1001 | RString ReadHtmlBodyText(QIStream& in, int langID) |
| 1002 | { |
| 1003 | char buf[4 * 1024]; |
| 1004 | int len = 0; |
| 1005 | int c = in.get(); |
| 1006 | while (!in.eof() && !in.fail() && c != '<') |
| 1007 | { |
| 1008 | if (c == 0x0a) |
| 1009 | { |
| 1010 | // avoid spaces at line end |
| 1011 | while (len > 0 && buf[len - 1] == ' ') |
| 1012 | { |
| 1013 | len--; |
| 1014 | } |
| 1015 | // avoid CR LF at begin of the text |
| 1016 | if (len == 0) |
| 1017 | { |
| 1018 | goto ReadTextContinue; |
| 1019 | } |
| 1020 | } |
| 1021 | if (c != 0x0d) // avoid CR LF -> 2 spaces (CRLF or LF are handled well) |
| 1022 | { |
| 1023 | if (ISSPACE(c)) |
| 1024 | { |
| 1025 | c = ' '; |
| 1026 | } |
| 1027 | else if (c == '&') |
| 1028 | { |
| 1029 | // ReadChar decodes the entity to a Latin-1 codepoint; emit it as UTF-8 |
| 1030 | // so it composes with the surrounding already-UTF-8 body. |
| 1031 | const unsigned char decoded = static_cast<unsigned char>(ReadChar(in)); |
| 1032 | len += Poseidon::Foundation::EncodeUtf8Codepoint(decoded, buf + len, sizeof(buf) - len); |
| 1033 | goto ReadTextContinue; |
| 1034 | } |
| 1035 | |
| 1036 | if (len < sizeof(buf) - 1) |