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

Add encoding parameter for non-ASCII characters #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuihao
Copy link

@kuihao kuihao commented Mar 18, 2024

Description

Fixed the UnicodeDecodeError issue in p2j when processing Python scripts with Chinese comments. Added an encoding parameter (default=“utf-8”) to handle character encoding. Resolves Issue #16.

Usage

Run code (OS is windows 11):

p2j .\code.py -e "Big5" # Specify the desired encoding (e.g., Big5)

Expected output:

Notebook .\code.ipynb written.

Fixed the `UnicodeDecodeError` issue in `p2j` when processing Python
scripts with Chinese comments. Added an encoding parameter
(default=“utf-8”) to handle character encoding. Resolves Issue remykarem#16.
Copy link
Owner

@remykarem remykarem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kuihao

Firstly, sorry for the late reply!

Secondly, thank you for taking the time to create a PR.

I've left a comment and it's a small change to expose this new feature in the CLI.

Thanks!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args.encoding should be passed to the encoding parameter that we're exposing in the functions jupyter2python and python2jupyter.

i.e.

if args.reverse:
  jupyter2python(
    ...,
    encoding=args.encoding
  )
else:
  python2jupyter(
    ...,
    encoding=args.encoding
  )

Otherwise, the value of the encoding parsed from the CLI won't enjoy this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants