or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/python-bidi@0.6.x
tile.json

tessl/pypi-python-bidi

tessl install tessl/pypi-python-bidi@0.6.0

Python Bidi layout wrapping the Rust crate unicode-bidi

Agent Success

Agent success rate when using this tile

93%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.09x

Baseline

Agent success rate without this tile

85%

task.mdevals/scenario-2/

Multi-Encoding Text Processor

Build a text processor that handles bidirectional text in multiple character encodings for a legacy document conversion system.

Requirements

Your solution must implement a function that processes text files containing right-to-left (RTL) content stored in various legacy encodings and prepares them for display.

Core Functionality

Implement a function process_text_file(data, encoding_name) that:

  • Accepts raw bytes as the first parameter
  • Accepts an encoding name (string) as the second parameter
  • Converts the bytes to displayable format while preserving the encoding type
  • Returns the processed bytes in the same encoding

The function should handle at least these encodings:

  • UTF-8 (utf-8)
  • Windows Hebrew (cp1255)
  • ISO Hebrew (iso-8859-8)

Test Cases

  • Processing UTF-8 encoded Hebrew text "שלום" (shalom) returns reversed bytes in UTF-8 encoding @test
  • Processing CP1255 encoded Hebrew text returns reversed bytes in CP1255 encoding @test
  • Processing ISO-8859-8 encoded Hebrew text returns reversed bytes in ISO-8859-8 encoding @test
  • Processing mixed English and Hebrew text maintains correct directionality for both scripts @test

Implementation

@generates

API

def process_text_file(data: bytes, encoding_name: str) -> bytes:
    """
    Process bidirectional text from bytes in the specified encoding.

    Args:
        data: Raw bytes containing text in the specified encoding
        encoding_name: The character encoding name (e.g., 'utf-8', 'cp1255', 'iso-8859-8')

    Returns:
        Processed bytes in the same encoding, with text reordered for display
    """
    pass

Dependencies { .dependencies }

python-bidi { .dependency }

Provides bidirectional text processing support for handling right-to-left scripts.