See How could the main.cpp read the parameters at platformio.ini? - #3 by maxgerhardt and Inject Board Name into Code - #2 by maxgerhardt for the correct string escaping technique.
For the documentation bug: I think I remember that that this is also OS-dependent and it works under Linux, but not universally. In any case, you should open an issue at Issues · platformio/platformio-docs · GitHub.