On Mon, Jun 10, 2013 at 9:11 AM, Mauro Bartolomeoli <
[email protected]> wrote:
> From my experience, it's not the parser duty to handle the encoding. This
> is usually done building a Reader using this weird syntax:
>
> new InputStreamReader(<input_stream>, encoding)
>
> but this assumes you already know the encoding of the stream you are going
> to read.
>
> In the past I used a framework (http://cpdetector.sourceforge.net/) that
> is able to guess encoding from a stream and built a Reader using it to have
> automatic encoding handling. CPDetector is a pluggable system using several
> heuristics to detect a stream encoding.
>
> I think Geotools / Geoserver are currently using the platform default
> encoding in many cases (for example reading SLD and freemarker templates)
> and this is often causing issues when transferring a data_dir to a
> different platform (for example from Windows to Linux).
>
> Maybe something similar to cpdetector could be used to avoid encoding
> issues like the above.
>
This totally makes sense, thank you.
Hum... cpdetector is half a megabyte, a wee bit too large.
However, the xml declaration is just one line, and I believe that one can
be read before reading the actual content.
Actually, see this one, it seems a parser can read the encoding if given
the right type of input:
http://stackoverflow.com/questions/3482494/howto-let-the-sax-parser-determine-the-encoding-from-the-xml-declaration
Cheers
Andrea
--
==
GeoServer training in Milan, 6th & 7th June 2013! Visit
http://geoserver.geo-solutions.it for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel