I have a simple Java web application deployed on AWS Elastic Beanstalk as a self-contained JAR file. It pulls values from environment variables to display them in web pages as HTML. Simplifying the application a bit, if I assign the environment variable PAGE_TEST = "foo\nbar", then when I go to the page /test then I will see the following, because my application parses out the lines into paragraphs
…
<p>foo</p>
<p>bar</p>
…
Encoding Problem
The first problem is that in Elastic Beanstalk, setting the environment variable PAGE_TEST to foo\nbar doesn't work! On the test page I get this:
…
<p>foonbar</p>
…
Apparently AWS Elastic Beanstalk is trying to interpret my backslash characters. Why? How can I turn this off? I want it just to use the exact values I give it! Who told it to try to evaluate the values as escape codes?
I can work around this by escaping the backslash as foo\\nbar, but I shouldn't have to!
Charset Problem
But now there is a worse problem. I set the environment variable PAGE_TEST to dança, which is a perfectly legitimate Unicode string—the Portuguese word for "dance". Unfortunately Elastic Beanstalk passes dan?a to my application.
…
<p>dan?a</p>
…
From experience I might guess that Elastic Beanstalk is trying to interpret the value as ASCII, and it is using a charset decoder that simply substitutes any non-ASCII character with ?. Or something. By why would it do that? It's 2020—what's wrong with just using Unicode?
Can someone help me tell AWS Elastic Beanstalk to stop mucking around with my perfectly valid environment variables and simply accept them as I provide them? I would be grateful.