cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-801701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EJMP%2018%20Comment%20ouvrir%20les%20fichiers%20py%20cod%C3%A9s%20uft-8%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-801701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EMon%20JMP%20est%20d%C3%A9j%C3%A0%20r%C3%A9gl%C3%A9%20sur%20%C2%AB%26nbsp%3Bgb2312%26nbsp%3B%C2%BB.%3CBR%20%2F%3E%20Il%20ne%20peut%20plus%20choisir%20l'encodage%20pour%20ouvrir%20ce%20fichier%20PY%20comme%20il%20ouvrirait%20un%20fichier%20txt.%3CBR%20%2F%3E%20Et%20JMP%20n'ex%C3%A9cute%20pas%20correctement%20ce%20code%20PY.%3CBR%20%2F%3E%20Je%20ne%20veux%20pas%20d%C3%A9finir%20JMP%20sur%20%C2%AB%26nbsp%3Butf-8%26nbsp%3B%C2%BB.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3EMerci!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222024-09-25_18-01-08.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222024-09-25_18-01-08.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222024-09-25_18-01-08.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222024-09-25_18-01-08.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F68562i1529F977CDDE7482%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222024-09-25_18-01-08.png%22%20alt%3D%222024-09-25_18-01-08.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-801701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAutomatisation%20et%20scripts%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFen%C3%AAtres%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-801712%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20JMP%2018%20Comment%20ouvrir%20les%20fichiers%20py%20cod%C3%A9s%20en%20uft-8%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-801712%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJe%20souhaite%20%C3%A9galement%20ouvrir%20les%20fichiers%20py%20avec%20cette%20option.%3CBR%20%2F%3E%20Merci%20les%20experts%20!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222024-09-25_18-25-26.png%22%20style%3D%22width%3A%20742px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222024-09-25_18-25-26.png%22%20style%3D%22width%3A%20742px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222024-09-25_18-25-26.png%22%20style%3D%22width%3A%20742px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F68563iCB7BBEC0E9A4D2CC%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222024-09-25_18-25-26.png%22%20alt%3D%222024-09-25_18-25-26.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-802131%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20JMP%2018%20Comment%20ouvrir%20les%20fichiers%20py%20cod%C3%A9s%20en%20uft-8%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-802131%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJMP%20initialise%20sp%C3%A9cifiquement%20Python%20en%20UTF-8.%20Vous%20pouvez%20essayer%20le%20m%C3%A9canisme%20Python%20standard%20pour%20sp%C3%A9cifier%20l'encodage%20de%20la%20source%20Python%2C%20par%20un%20%C2%AB%20commentaire%20magique%20%C2%BB%20dans%20la%20source.%20Cependant%2C%20%C3%A9tant%20donn%C3%A9%20que%20JMP%20initialise%20Python%20une%20seule%20fois%20par%20ex%C3%A9cution%20de%20JMP%2C%20je%20ne%20suis%20pas%20s%C3%BBr%20que%20la%20technique%20ci-dessous%20fonctionnera.%20Si%20cela%20fonctionne%2C%20il%20faudrait%20que%20ce%20soit%20la%20toute%20premi%C3%A8re%20ex%C3%A9cution%20de%20script%2C%20mais%20m%C3%AAme%20cela%20peut%20%C3%AAtre%20trop%20tard%20car%20JMP%20ex%C3%A9cute%20en%20interne%20quelques%20petits%20scripts%20Python%20pour%20configurer%20l'environnement.%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3EVoir%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fpeps.python.org%2Fpep-0263%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpeps.python.org%2Fpep-0263%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EPython%20utilisera%20par%20d%C3%A9faut%20l'ASCII%20comme%20codage%20standard%20si%20aucune%20autre%20indication%20de%20codage%20n'est%20donn%C3%A9e.%3C%2FP%3E%0A%3CP%3EPour%20d%C3%A9finir%20un%20encodage%20de%20code%20source%2C%20un%20commentaire%20magique%20doit%20%C3%AAtre%20plac%C3%A9%20dans%20les%20fichiers%20sources%20soit%20comme%20premi%C3%A8re%20ou%20deuxi%C3%A8me%20ligne%20du%20fichier%2C%20par%20exemple%26nbsp%3B%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight-default%20notranslate%22%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%3E%3CSPAN%20class%3D%22c1%22%3E%23%20coding%3D%3CENCODING%20name%3D%22%22%3E%3C%2FENCODING%3E%3C%2FSPAN%3E%0A%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3Eou%20(en%20utilisant%20des%20formats%20reconnus%20par%20les%20%C3%A9diteurs%20populaires)%26nbsp%3B%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight-default%20notranslate%22%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%3E%3CSPAN%20class%3D%22ch%22%3E%23!%2Fusr%2Fbin%2Fpython%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22c1%22%3E%23%20-*-%20coding%3A%20%3CENCODING%20name%3D%22%22%3E%20-*-%3C%2FENCODING%3E%3C%2FSPAN%3E%0A%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3Eou%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight-default%20notranslate%22%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%3E%3CSPAN%20class%3D%22ch%22%3E%23!%2Fusr%2Fbin%2Fpython%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22c1%22%3E%23%20vim%3A%20set%20fileencoding%3D%3CENCODING%20name%3D%22%22%3E%20%3A%3C%2FENCODING%3E%3C%2FSPAN%3E%0A%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3EPlus%20pr%C3%A9cis%C3%A9ment%2C%20la%20premi%C3%A8re%20ou%20la%20deuxi%C3%A8me%20ligne%20doit%20correspondre%20%C3%A0%20l'expression%20r%C3%A9guli%C3%A8re%20suivante%26nbsp%3B%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight-default%20notranslate%22%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%3E%3CSPAN%20class%3D%22o%22%3E%5E%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E%5B%3C%2FSPAN%3E%20%5C%3CSPAN%20class%3D%22n%22%3Et%3C%2FSPAN%3E%5C%3CSPAN%20class%3D%22n%22%3Ef%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E%5D%3C%2FSPAN%3E%3CSPAN%20class%3D%22o%22%3E*%3C%2FSPAN%3E%3CSPAN%20class%3D%22c1%22%3E%23.*%3Fcoding%5B%3A%3D%5D%5B%20%5Ct%5D*(%5B-_.a-zA-Z0-9%5D%2B)%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3ESi%20cela%20ne%20r%C3%A9sout%20pas%20le%20probl%C3%A8me%2C%20veuillez%20contacter%20le%20support%20technique%20JMP%20et%20d%C3%A9poser%20un%20rapport%20de%20bogue.%20Je%20demanderai%20%C3%A0%20notre%20%C3%A9quipe%20de%20test%20de%20v%C3%A9rifier%20les%20variantes%20o%C3%B9%20l'encodage%20JMP%20utilis%C3%A9%20n'est%20pas%20UTF-8.%3C%2FP%3E%3C%2FLINGO-BODY%3E
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.