cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
lala
Level VIII

JMP 18 How to open uft-8 encoded py files?

My JMP is already set to "gb2312".
It can no longer choose the encoding to open this PY file the way it would open a txt file.
And JMP does not run this PY code correctly.
I don't want to set JMP to "utf-8".

 

Thanks!

2024-09-25_18-01-08.png

2 REPLIES 2
lala
Level VIII

Re: JMP 18 How to open uft-8 encoded py files?

I want to open py files with this option as well.
Thanks Experts!

2024-09-25_18-25-26.png

Re: JMP 18 How to open uft-8 encoded py files?

JMP specifically initializes Python as UTF-8.  You can try the standard Python mechanism for specifying the encoding of the Python source, by a 'magic comment' in the source.  However, since JMP initializes Python only once per run of JMP I'm not sure that this technique below will work.  If it does work, it would have to be the very first script run, but even that may be too late as JMP internally runs some small Python scripts to set up the environment. 

 

See: https://peps.python.org/pep-0263/

Python will default to ASCII as standard encoding if no other encoding hints are given.

To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as:

# coding=<encoding name>

or (using formats recognized by popular editors):

#!/usr/bin/python
# -*- coding: <encoding name> -*-

or:

#!/usr/bin/python
# vim: set fileencoding=<encoding name> :

More precisely, the first or second line must match the following regular expression:

^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)

If this does not solve the issue, please contact JMP Technical Support and file a bug report.  I will ask our testing team to check out variations where JMP encoding used is not UTF-8.