0

When I use an SLD file exported from QGIS to create a new style in GeoServer and then preview the style, there is an issue with the legend name displaying as garbled characters. QGIS windows as follows.

enter image description here

The appearance after importing into GeoServer is as follows (I simplified the SLD for a complete view).

enter image description here

However, when I open the WMS service in ArcGIS Pro, the legend display is normal, as shown in the following image. enter image description here I would like to know why the Chinese labels for the symbol system are garbled during preview, but the legend in the service appears normal. SLD content follows

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0" xmlns:se="http://www.opengis.net/se" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <se:Name>样式测试</se:Name>
    <UserStyle>
      <se:Name>样式测试</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>冰川及永久积雪</se:Name>
          <se:Description>
            <se:Title>冰川及永久积雪</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>ejlmc</ogc:PropertyName>
              <ogc:Literal>冰川及永久积雪</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#d7191c</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
8
  • I can't reproduce on my machine, can you add some details of how you upload the file, what your operating system is
    – Ian Turton
    Sep 8 at 10:53
  • Thank you for your attention to my question. I am using the Windows 10 Professional edition system, Geoserver version 2.23.2. My SLD file was exported in QGIS 3.28.9, and I imported it through the GeoServer style interface to create a new style.
    – 苏云明
    Sep 11 at 1:29
  • I also would like to know what system you are using. Do you encounter garbled characters when previewing the symbol system? By garbled characters, I mean that the displayed Chinese characters do not match the ones I have configured.
    – 苏云明
    Sep 11 at 1:32
  • I'm using Linux and have my system set to use UTF-8 by default - I get exactly the same characters in the legend as in the SLD file.
    – Ian Turton
    Sep 11 at 7:43
  • I changed the encoding of the Windows system to UTF-8, and now Chinese characters display correctly. However, this configuration currently affects the usage of other software. For example, when I create a Chinese folder in NFS without configuring UTF-8, it displays as garbled text.
    – 苏云明
    Sep 11 at 10:24

2 Answers 2

0

The problem seems to be that your system is running with a default encoding that is not UTF-8 but that QGIS saves the file with a UTF-8 encoding. So GeoServer uses the default encoding and not the UTF-8 that QGIS intended.

I changed the encoding of the Windows system to UTF-8, and now Chinese characters display correctly. However, this configuration currently affects the usage of other software. For example, when I create a Chinese folder in NFS without configuring UTF-8, it displays as garbled text.

The solution is to configure QGIS to use your default encoding or convert the file to UTF-8 before uploading it.

0

Thanks for Ian Turton's response, here I'd like to add how to modify the encoding on a Windows system. The specific steps are as follows: Control Panel -> Clock and Region -> Region -> Administrative -> Change system locale... -> Check 'Beta... UTF-8...' as shown in the screenshot below. enter image description here

Your Answer

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

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