← Winnitude! Search  ·  Reader Mode (1158 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 14 LINKS

Possible bug in reading zero width no-break space character · Issue #2369 · pythonnet/pythonnet

Repository navigation

Possible bug in reading zero width no-break space character  #2369


New issue

New issue

Closed
#2370
Closed
Possible bug in reading zero width no-break space character #2369 #2370 Labels
bug
Milestone 3.0.4

Description

@AviParikh's profile AviParikh opened on May 2, 2024

Environment

  • Pythonnet version: 3.0.3
  • Python version: 3.10
  • Operating System: Windows 11
  • .NET Runtime: 8.0.4

Details

  • Describe what you were trying to get done.

I want to read a file that may contain zero width no-break space characters anywhere in the file. If I read a file using C# into Python using Python.NET, these characters get dropped if they are at the start of a line.

from pythonnet import load
load("coreclr")
import clr
clr.AddReference('System')
clr.AddReference('System.Runtime')
clr.AddReference('System.IO')

import System
file_path = r"path\to\zwnbsp_test_data.txt"

result = System.IO.File.ReadAllLines(file_path)
print(str(result[1][0]))

Native C# code does not seem to have this problem:

C#
String[] lines = File.ReadAllLines(@"path\to\zwnbsp_test_data.txt");

int firstChar = char.ConvertToUtf32(lines[1], 0);
int secondChar = char.ConvertToUtf32(lines[1], 1);
Console.WriteLine(firstChar);
Console.WriteLine(secondChar);

zwnbsp_test_data.txt

Some screenshots to help illustrate:

  • If there was a crash, please include the traceback here.
    No crash

Metadata

Metadata

Assignees

No one assigned

    Labels


    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions