Question
Anderson Negreli · Jan 2

Encoding error in Studio output - Embedded Python

 Hello, good afternoon! (or good morning or good evening)
 

I was doing some very basic tests, based on the documentation, using Python in Studio.
I decided to call a python method through the Studio's own terminal as a demonstration, but the result was different from the terminal result:

Code:

Class User.EmbeddedPython
{

// Write ##class(User.EmbeddedPython).Test()
/// Description
ClassMethod Test() As %Status [ Language = python ]
{
    # print the members of the Fibonacci series that are less than 10
    print("Fibonacci series")
    a, b = 0, 1
    while a < 10:
        print(a, end=' ')
        a, b = b, a + b

    # import the iris module and show the classes in this namespace
    import iris
    print("\nInterSystems IRIS classes in this namespace:")
    status = iris.cls('%SYSTEM.OBJ').ShowClasses()
    return status
}

}

Terminal (as expected):

 

Studio:

Class name came out correctly, but what was put in a Python String came out wrong.

I tested the same class on other IRIS installations and the error persisted.


Does anyone know a way to fix this?

Thanks in advance for your attention.

Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1.1 (Build 374U)
1
0 127
Discussion (3)1
Log in or sign up to continue

Looks like an encoding issue.
Encoding in Studio is most likely different from your terminal settings.
And phyton has no idea about your surface settings.

Run this line in Studio and in Terminal and you see what's happening.
Matching ends after the end of 7bit ASCII encoding.

f j=0:1:64 w ! f i=0:1:63 w $c(j*64+i)

Yes, Studio terminal is not a true terminal and does not work with Unicode, try:

w "Привет"

and you'll also get a similarly garbled output.

Oh, this information is very helpful.
I've always considered Studio's terminal to be a true terminal, good to know.

Thanks for the answer.