Ошибка многострочного HTML-кода

Я видел несколько способов создания многострочного HTML, но один из них мне показался более удобным (за исключением того, что есть способ разместить HTML на отдельной странице, что было бы здорово). Тем не менее я получаю сообщение об ошибке при попытке скомпилировать его на Arduino Ide. Это ошибки, которые я получаю:

bitluniHomeAutomation:64: error: stray '\342' in program
const char* msj = R”foo(
^
bitluniHomeAutomation:64: error: stray '\200' in program
bitluniHomeAutomation:64: error: stray '\235' in program
bitluniHomeAutomation:70: error: stray '#' in program
background-color: #990033;
^
bitluniHomeAutomation:77: error: stray '\342' in program
</style>”
^
bitluniHomeAutomation:77: error: stray '\200' in program
bitluniHomeAutomation:77: error: stray '\235' in program
bitluniHomeAutomation:78: error: stray '\342' in program
</head>”
^
bitluniHomeAutomation:78: error: stray '\200' in program
bitluniHomeAutomation:78: error: stray '\235' in program
bitluniHomeAutomation:79: error: stray '\342' in program
<body>”
^
bitluniHomeAutomation:79: error: stray '\200' in program
bitluniHomeAutomation:79: error: stray '\235' in program
bitluniHomeAutomation:80: error: stray '\342' in program
<input type=”button” class=”button” value=”Input Button”>
^
bitluniHomeAutomation:80: error: stray '\200' in program
bitluniHomeAutomation:80: error: stray '\235' in program
bitluniHomeAutomation:80: error: stray '\342' in program
bitluniHomeAutomation:80: error: stray '\200' in program
bitluniHomeAutomation:80: error: stray '\235' in program
bitluniHomeAutomation:80: error: stray '\342' in program
bitluniHomeAutomation:80: error: stray '\200' in program
bitluniHomeAutomation:80: error: stray '\235' in program
bitluniHomeAutomation:80: error: stray '\342' in program
bitluniHomeAutomation:80: error: stray '\200' in program
bitluniHomeAutomation:80: error: stray '\235' in program
bitluniHomeAutomation:80: error: stray '\342' in program
bitluniHomeAutomation:80: error: stray '\200' in program
bitluniHomeAutomation:80: error: stray '\235' in program
bitluniHomeAutomation:80: error: stray '\342' in program
bitluniHomeAutomation:80: error: stray '\200' in program
bitluniHomeAutomation:80: error: stray '\235' in program
bitluniHomeAutomation:83: error: missing terminating " character
)foo";
^
/Users/carlospiasentini/Documents/Arduino/bitluniHomeAutomation/bitluniHomeAutomation.ino: In function 'void cssButton()':
bitluniHomeAutomation:64: error: 'R' was not declared in this scope
const char* msj = R”foo(
^
bitluniHomeAutomation:77: error: expected ',' or ';' before '<' token
</style>”
^
bitluniHomeAutomation:85: error: 'message' was not declared in this scope
message.replace("[[MODE]]", String(inputMode));
^
bitluniHomeAutomation:85: error: 'inputMode' was not declared in this scope
message.replace("[[MODE]]", String(inputMode));
^
exit status 1
stray '\342' in program

И это мой HTML-код

void cssButton() {
const char* msj = R”foo(
<!DOCTYPE html>
<html>
<head>
<style>
.button {
background-color: #990033;
border: none;
color: white;
padding: 7px 15px;
text-align: center;
cursor: pointer;
}
</style>”
</head>”
<body>”
<input type=”button” class=”button” value=”Input Button”>
</body>
</html>
)foo";
String message = String(msj);
message.replace("[[MODE]]", String(inputMode));
server.send(200, "text/html", message);
}

Я называю это так:

server.on("/button", cssButton);

0

Решение

Я полагаю, вы компилируете чип ESP8266 в Arduino IDE.

Обратите внимание, что в вашем коде у вас есть:

const char* msj = R”foo(

Здесь вы использовали фигурные цитаты который НЕ символ ASCII.

Для того же эффекта, вы можете использовать символ ASCII -> « <-

Какой номер 34, как показано в этом ASCII таблица.

1

Другие решения

В дополнение к вышесказанному, вам также необходимо убедиться, что любые кавычки, которые появляются внутри вашей строки, например, в <input type=”button” class=”button” value=”Input Button”> сбежали. В противном случае компилятор будет рассматривать их как конец строки в кавычках и попытаться проанализировать то, что следует после, как оператор.

Чтобы избежать их, добавьте обратную косую черту, например так: <input type=\"button\" class=\"button\" value=\"Input Button\">,

В качестве альтернативы вы можете использовать одинарные кавычки везде внутри вашего HTML. Они не будут конфликтовать с двойными кавычками, содержащими весь HTML.

0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector