java - What encoding should I use for an HTTP servlet input stream if none was specified? -
while reading servletinputstream
team doing this:
br = new bufferedreader(new inputstreamreader(servletinputstream));
this unsurprisingly gave red flag on code analyzer encoding not specified , rely on whatever default system encoding is.
the first step try encoding request:
string encoding = request.getcharacterencoding(); if (encoding != null) { br = new bufferedreader(new inputstreamreader(servletinputstream), encoding); }
however, this related answer told me, browsers don't send encoding, cause encoding
null above. in case, how on earth supposed know encoding is?
do browsers not send encoding because:
- there universally-agreed default encoding http requests used if none specified? (if , standard defines should used), or,
- there other way determine encoding is? (if it? surely not trying different encodings , seeing whether garbage or parseable?)
since dynamic web application, you'd expected have control on encoding clients post request. utf-8.
Comments
Post a Comment