2017-06-01 50 views
0

我已經看到了多行的多行HTML的方法,但我發現更方便的是這一個,(除了有一個方法,在一個單獨的頁面上的HTML將是可怕的)。不過,當我嘗試在arduino ide上進行編譯時出現錯誤。這是我得到的錯誤:多行HTML代碼錯誤

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); 
+3

您正在使用捲曲的引號。別。 –

+4

您的程序中有捲曲的引號。你必須使用ASCII雙引號。 – Barmar

+0

[爲什麼此字符的ASCII表示形式返回爲226 128 153?]可能重複(https://stackoverflow.com/questions/28286059/why-is-ascii-representation-of-this-character-returns-as- 226-128-153) –

回答

1

我相信你是在編譯的ESP8266芯片Arduino IDE。

注意,在你的代碼中有:

const char* msj = R」foo(

這裏你已經使用了彎引號這是不是一個ASCII字符。

達到同樣的效果,你可以使用ASCII字符 - > < -

這是如本ASCII table 34號

0

除上述外,您還可以需要確保出現在你的字符串中的任何引號,例如在<input type=」button」 class=」button」 value=」Input Button」>中,否則編譯器會將它們當作引用字符串的結尾,並嘗試解析後面的內容作爲語句。

逃避他們,預先安排一個反斜槓,如下所示:<input type=\"button\" class=\"button\" value=\"Input Button\">

或者,您可以在HTML內部的任何位置使用單引號。這些不會與包含整個HTML的雙引號衝突。