html_inside_cpp icon indicating copy to clipboard operation
html_inside_cpp copied to clipboard

note on string literal size and double quotes

Open btsimonh opened this issue 6 years ago • 2 comments

Just found this and love it. But... note that MS limits string literals to 16384 (from https://stackoverflow.com/questions/16868362/c-string-too-big-trailing-characters-truncated). Also, this construct in js inside an html foxed it: index = index ? index[1].replace(/"/g, '"') : '';

  • error was 'error C2001: newline in constant' (vs 2015).

btsimonh avatar Jul 18 '17 18:07 btsimonh

Thanks! I thought I'm the only one who liked it :)

Probably there's a way to fix one of those limitations by using raw string literals. Are you interested in such fix? Do you use C++11?

apolukhin avatar Jul 18 '17 19:07 apolukhin

I'm using c++11 capable compiler, but quite conservative with what I use.. so not really genned up on what c++11 adds :). What may this involve?

I'm actually considering how I 'protect' the html/js; although at the end of the day, it's going to be loaded into a browser, so can't be 'protected'; however it may mean I at least have a build step involved which will minify/uglify the js. It's funny how a search for 'how to embed html inside a c application' is so hard to do; I spend at least 2 hours googling and came up blank - maybe this is why your's has not been found easily - EVERY webpage contains the word 'html' !!!

btsimonh avatar Jul 18 '17 20:07 btsimonh