Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

BUG UnicodeReplacementConverter writes characters outside the BMP as invalid five-digit \u escapes

Open Beginner friendly
#3,130 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@ShivamSharma43 is already working on this.

Since Oct 11, 2026.

  • #3132 by @ShivamSharma43 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Read UnicodeReplacementConverter and compare its output with JsonStringConverter, which the issue says already emits the expected surrogate pair. Reproduce with the provided Python snippet using an emoji and confirm BMP characters retain their current output. Done when non-BMP characters are represented as valid UTF-16 surrogate pairs and the reproduction decodes to the original text.

Written by the indexing model from the issue text.

Description

Describe the bug

UnicodeReplacementConverter formats each character as \u{ord(ch):04x}. :04x is a minimum width, so a character outside the Basic Multilingual Plane (emoji, many CJK extension characters, math alphanumerics) gets five or six hex digits. A \u escape holds exactly four in JSON, JavaScript, Java and Python, so the output decodes to a different character followed by a stray digit.

To Reproduce

import asyncio, json
from pyrit.converter import UnicodeReplacementConverter

out = asyncio.run(UnicodeReplacementConverter().convert_async(prompt="hi 😀")).output_text
print(out)                       # hi ὠ0
print(json.loads(f'"{out}"'))    # hi ὠ0

Expected behavior

😀 is written as its UTF-16 surrogate pair, 😀, which is what JsonStringConverter already emits for the same character. BMP characters keep their current output.

Version

main at 60c3386a, Python 3.11, Windows.

Dominant language
Python
Stars
4.6k
Forks
944
Avg merge
2d 20h
Merged PRs (30d)
309

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/PyRIT

All issues in microsoft/PyRIT

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.