Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading styles with utf-8 chars fails with UnicodeDecodeError #248

Open
gannebamm opened this issue Apr 28, 2022 · 2 comments · May be fixed by #272
Open

loading styles with utf-8 chars fails with UnicodeDecodeError #248

gannebamm opened this issue Apr 28, 2022 · 2 comments · May be fixed by #272

Comments

@gannebamm
Copy link

I should be able to load this dataset:
https://master.demo.geonode.org/catalogue/#/dataset/916

But it fails with:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 110: invalid continuation byte 
Traceback (most recent call last):
  File "C:\Users/hoedt/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis_geonode\gui\search_result_widget.py", line 235, in handle_layer_detail
    dataset.to_json() if dataset is not None else None,
  File "C:\Users/hoedt/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis_geonode\apiclient\models.py", line 165, in to_json
    serialized_sld = qgis_geonode_styles.serialize_sld_named_layer(
  File "C:\Users/hoedt/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis_geonode\styles.py", line 50, in serialize_sld_named_layer
    return buffer_.data().decode(encoding="utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 110: invalid continuation byte

Which is rooted in the utf-8 style name of the SLD:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <se:Name>test äöü</se:Name>
    <UserStyle>
      <se:Name>test äöü</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>test äöü</se:Name>
          <se:PointSymbolizer>
            <se:Graphic>
              <se:Mark>
                <se:WellKnownName>square</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#cc0003</se:SvgParameter>
                </se:Fill>
              </se:Mark>
              <se:Size>6</se:Size>
            </se:Graphic>
          </se:PointSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

The same (cloned) dataset without utf-8 chars in the name and title field does work:
https://master.demo.geonode.org/catalogue/#/dataset/915

@gannebamm
Copy link
Author

The dataset
https://master.demo.geonode.org/catalogue/#/dataset/916

Was not publicly available. I fixed that to provide a (non) working example

@giohappy
Copy link
Contributor

@ricardogsilva I faced the same error today. Moreover, the error breaks the rest of the plugin's functionality.
A restart of QGIS is needed to restore it.

utf8 issue qgis plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants