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

UTF8 encoding messy code #5193

Open
xiaoxstz opened this issue Mar 12, 2024 · 2 comments
Open

UTF8 encoding messy code #5193

xiaoxstz opened this issue Mar 12, 2024 · 2 comments
Labels
C-bug Something isn't working

Comments

@xiaoxstz
Copy link

Summary

It does not support utf-8 encoding yet?

Expected

When running scripts with Chinese strings, it would come across messy code issues.

For example, the script below.

print("测试中文")
# coding=utf-8
print("测试中文")

The output is:

娴嬭瘯涓枃

Actual

Python Documentation

@xiaoxstz xiaoxstz added the C-bug Something isn't working label Mar 12, 2024
@youknowone
Copy link
Member

youknowone commented Mar 13, 2024

RustPython (almost) only support utf-8 and ascii. Would you check if your source code is a correct utf-8 file? If you keep having the problem, please upload the source code file too. It will be really helpful.

Welcome to the magnificent Rust Python 0.3.0 interpreter 😱 🖖
RustPython 3.12.0
Type "help", "copyright", "credits" or "license" for more information.
>>>>> print("测试中文")
测试中文
>>>>> 
❯ ./target/debug/rustpython test_utf8_zh.py
测试中文

@xiaoxstz
Copy link
Author

My Environment

  • OS:Windows 10 pro 22H2
  • How to install RustPython
# Install rust
scoop install main/rust
# Install the latest RustPython
cargo install --git https://github.com/RustPython/RustPython

File encoding

I have ensured the encoding of the Python script file is utf8

Encoding-vscode

Other related issue

I have also found the issue in the interactive panel

D:\Desktop                                                             
λ RustPython                                                           
Welcome to the magnificent Rust Python 0.3.0 interpreter � �           
RustPython 3.12.0                                                      
Type "help", "copyright", "credits" or "license" for more information. 
>>>>> print("测试中文")                                                    
娴嬭瘯涓枃                                                                 
>>>>>                                                                  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants