Bug report #19124

UTF-8 characters not supported in python script despite # -*- coding: utf-8 -*-

Added by Yannick Portier over 2 years ago. Updated about 2 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:PyQGIS Console
Affected QGIS version:3.0.3 Regression?:No
Operating System:Win64 Easy fix?:No
Pull Request or Patch supplied:No Resolution:worksforme
Crashes QGIS or corrupts data:No Copied to github as #:26954

Description

The following lines generate an error "SyntaxError: invalid character in identifier"
ϕ = radians(latitude)
λ = radians(longitude)

Even with the script having these first two lines
#!/usr/bin/env python
  1. coding: utf-8

GeodeticToGeocentric.py Magnifier (1.05 KB) Yannick Portier, 2018-06-12 05:37 PM

History

#1 Updated by Matthias Kuhn over 2 years ago

  • Status changed from Open to Feedback

Please provide a full minimal working example.

#2 Updated by Yannick Portier over 2 years ago

Here is a code sample

#3 Updated by Jürgen Fischer about 2 years ago

  • Resolution set to worksforme
  • Status changed from Feedback to Closed

Pasting this into the python console works fine for me - both on Windows and Linux. On the command line you have to make sure that you're actually using python3 ad python2 doesn't support non-ascii identifiers (ie. on OSGeo4W by running call py3_env.bat. On Linux you might need #!/usr/bin/env python3 is python 2 is otherwise used).

Also available in: Atom PDF