Details
Description
Quoting my letter sent to GeoServer mailing list:
It seems that WMS's GetFeatureInfo request is partially affected with
that default character encoding issue. When asking for GetFeatureInfo
with "info_format" of "text/plain", "text/html" or without specifying
output format at all (in that case format defaults to "text/plain"
which is a bit surprising for me; I would rather expect GML2 to be
a default one) I see those nasty question marks instead of cyrillic
letters.
I believe the above behavior is caused by the way in which `writeTo()`
method of
`org.vfny.geoserver.responses.wms.featureInfo.TextFeatureInfoResponse`
and
`org.vfny.geoserver.responses.wms.featureInfo.HTMLTableFeatureInfoResponse`
classes construct their PrintWriter object.
That looks like this:
public void writeTo(OutputStream out)
...
PrintWriter writer = new PrintWriter(out);
As stated by Sun's javadocs, OutputStream-based constructor of
PrintWriter "creates the necessary intermediate OutputStreamWriter,
which will convert characters into bytes using the default character
encoding".
I think it would be more appropriate not to rely on this automagical
conversion but construct OutputStreamWriter explicitly using the
character encoding from "services.xml" file. I.e. after replacing
PrintWriter writer = new PrintWriter(out);
with
OutputStreamWriter osw = new OutputStreamWriter(out,
getRequest().getGeoServer().getCharSet());
PrintWriter writer = new PrintWriter(osw);
in both TextFeatureInfoResponse.java and HTMLTableFeatureInfoResponse.java
the things are definitely straightens up ![]()
`GmlFeatureInfoResponse` class is not affected by this since it is
aware of "charSet" configuration setting.
Set fix version to 1.2.4, assigned to me.