0

I am creating some new style with Postman. The main problem is that the new style was created with Unicode problem. It means I am seeing the new style has some character that are not Unicode.

URL : http://localhost:8090/geoserver/rest/workspaces/webgis/styles

HTTP Post

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
<Name>export_output8464daf0723</Name>
<UserStyle>
<Title>export_output8464daf071</Title>
<Name>export_output8464daf0732</Name>
 <FeatureTypeStyle>
   <Rule>
       <Name>export_output8464daf071_site_name_1</Name>
       <Title>export_output8464daf071_site_name_1_تپه قورچی</Title>
       <ogc:Filter>
         <ogc:PropertyIsEqualTo>
           <ogc:PropertyName>site_name</ogc:PropertyName>
           <ogc:Literal>تست</ogc:Literal>
         </ogc:PropertyIsEqualTo>
       </ogc:Filter>
       <PointSymbolizer>
          <Graphic>
         <Mark>
           <WellKnownName>circle</WellKnownName>
           <Fill>
             <CssParameter name="fill">#bd8321</CssParameter>
           </Fill>
         </Mark>
         <Size>2</Size>
       </Graphic>
     </PointSymbolizer>
   </Rule>
 </FeatureTypeStyle>
</UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

and Content type is :

application/vnd.ogc.sld+xml

Style in GeoServer is :

<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
  <sld:NamedLayer>
    <sld:Name>export_output8464daf0732</sld:Name>
    <sld:UserStyle>
      <sld:Name>export_output8464daf0732</sld:Name>
      <sld:Title>export_output8464daf071</sld:Title>
      <sld:FeatureTypeStyle>
        <sld:Name>name</sld:Name>
        <sld:Rule>
          <sld:Name>export_output8464daf071_site_name_1</sld:Name>
          <sld:Title>export_output8464daf071_site_name_1_ط·ع¾ط¸آ¾ط¸â€، ط¸â€ڑط¸ث†ط·آ±ط¹â€ ط؛إ’</sld:Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>site_name</ogc:PropertyName>
              <ogc:Literal>ط·ع¾ط·آ³ط·ع¾</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <sld:PointSymbolizer>
            <sld:Graphic>
              <sld:Mark>
                <sld:WellKnownName>circle</sld:WellKnownName>
                <sld:Fill>
                  <sld:CssParameter name="fill">#bd8321</sld:CssParameter>
                </sld:Fill>
              </sld:Mark>
              <sld:Size>2</sld:Size>
            </sld:Graphic>
          </sld:PointSymbolizer>
        </sld:Rule>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:NamedLayer>
</sld:StyledLayerDescriptor>
4
  • On my Ubuntu 20.04 box this works fine with curl and both ascii and binary data options. Are you on a windows machine by any chance?
    – Ian Turton
    Aug 12, 2020 at 8:03
  • @IanTurton Thank you . Yes it is windows server ... Aug 12, 2020 at 10:45
  • try "application/vnd.ogc.sld+xml;charset=UTF-8" as the content-type
    – Ian Turton
    Aug 12, 2020 at 12:57
  • I did it but the result is same :-( Aug 12, 2020 at 16:07

1 Answer 1

1

After a lot of googling , I understood Java on windows does NOT support Unicode output by default. As we know, GeoServer made by JAVA too, so we have to do some stuff for fixing this issue.

1. Add this variable to your System Environment Variable.

JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 

2. Open CMD (RUN AS Administrator) and run this command

C:\WINDOWS\system32>chcp 65001

and you will see this message : Active code page: 65001

Point 1 : Do not forget to restart your computer or 1 - close your explorer and open it and then 2 - restart you GeoServer service from Services.

Point 2 : Your XML should be start with :

<?xml version="1.0" encoding="UTF-8"?>

Point 3 : You do not need to add charset=UTF-8 in end of Content-Type. So you can set to :

Content-Type=application/vnd.ogc.sld+xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.