MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ReadText

Function ReadText

engine/Poseidon/UI/Controls/UIControlsExt.cpp:991–1033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989 else if (strcmp(buf, "yuml") == 0)
990 {
991 return (char)255;
992 }
993 else
994 {
995 return '?';
996 }
997}
998
999namespace Poseidon
1000{
1001RString 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)

Callers 1

LoadBufferMethod · 0.70

Calls 5

ReadCharFunction · 0.70
getMethod · 0.45
eofMethod · 0.45
failMethod · 0.45
ungetMethod · 0.45

Tested by

no test coverage detected