Properly escaping very large strings On an esp8266 I want to create a little webserver that shows me a dashboard with charts and stuff. For this I wanna include the echarts-library as it works offline. To access it the only way I can see this working is that I write `
const char libData[784674] PROGMEM = &quot;the entire 700 KB library goes here&quot;;

And then deliver it on request with server.on('./echarts.min.js', handleLibRequest) or something like that.
Now my problem is that in this 700KB of text there are ' and &quot; characters all scattered arround. The C++11 way of R(&quot;hard escapable '&quot;'''&quot; string&quot;) isn't working in my environment. How would one go about this to include this file in my code?
Is there mybe some way utilize the preprocessor for this? Or maybe an online tool that converts &quot;str&quot; to ['s','t','r']?
You could write a simple program that escapes all the offending characters and use the output of that in your const char libData[]; see here for a list of escape sequences;
You could serve the library directly from a (pseudo) file system on the ESP8266, without having to copy it &quot;manually&quot; into a variable; you just copy the file to the filesystem;
You could Base64-encode the library and manually copy the result into const char libData[], then Base64-decode before sending;
What I like to do, if there is no file system but enough memory:

Gzip the library;
Base64-encode the .gz file;
Copy the Base-64 encoded result by hand into your const char libData[].

Despite the Base64 encoding, the gzipping makes the end result smaller than the original, which helps with memory usage and transfer speed, and it will have no &quot;quote problems&quot;.
When the libData needs to be served, Base64-decode it, and send the resulting (gzipped) data to the client; all browsers I know will accept that if you add the Content-Encoding: gzip header.
Example code on a raw client without a webserver library: unsigned int sendBase64Page() (mind the content type).