gicait / geoserver-rest

Python library for management of geospatial data in GeoServer.
https://geoserver-rest.readthedocs.io
MIT License
197 stars 79 forks source link

Use upload_style to add a style Chinese garbled #158

Open mengqiuzl opened 4 months ago

mengqiuzl commented 4 months ago

I'm using the upload_style method in the geoserver-rest api to add a new style, and my sld file contains Chinese fields, and after adding it, Chinese garbled characters. Here are my sld files: 县.zip image

iamtekson commented 4 months ago

Have you got any issues after uploading? If you have the error message, please attach it too.

mengqiuzl commented 4 months ago

from geo.Geoserver import Geoserver

geo = Geoserver(
    "http://localhost:8089/geoserver", username="admin", password="geoserver"
)
geo.upload_style(
    path="style/县.sld",
    name="teststyle123",
    workspace="mengqiu",
    sld_version="1.1",
)

The SLD file I uploaded is encoded in UTF-8, but the Chinese garbled code is cleared in the style, similar to this: This is the source file: 屏幕截图 2024-07-24 084807 This is after uploading: 屏幕截图 2024-07-24 084458

iamtekson commented 4 months ago

It looks weird. Have you tried directly uploading the SLD to the geoserver? Also, it is better to check the geoserver log file. I have no idea about this issue.

mengqiuzl commented 4 months ago

Manually add the style file and save it to the geoserver, if the sld file has Chinese, the file encoding will change to GB2312, if there is no Chinese file encoding will be uft-8. Upload the sld file via geoserver-rest, no matter what encoding format the sld file, it will be saved as uft-8 after uploading, here the sld file encoding containing Chinese is not changed to GB2312, this is the main reason for the garbled Chinese, is there any way you can solve this problem? Thank you very much.