Skip to content

SegyFactory.create_textual_header() raises UnicodeEncodeError #291

@ajmalrasi

Description

@ajmalrasi

Issue

SegyFactory.create_textual_header() throws a UnicodeDecodeError on some EBCDIC characters, even though SegyFile.text_header can already read and print the same header. The two code paths should behave the same way.


Steps to Reproduce

from mdio.segy import SegyFile, SegyFactory, get_segy_standard

segy_path = "gs://tgs-geophysical-test-samples/AP_Data/900_General/WeirdCharinEBCDIC.sgy"

# 1. Read the file
sreader = SegyFile(segy_path)          # Works
print(sreader.text_header)             # Works (shows weired chars)

factory = SegyFactory(
    spec=get_segy_standard(1.0),
    samples_per_trace=2001,
    sample_interval=4_000,
)

txt = factory.create_textual_header(sreader.text_header)  # Fails

Error:
UnicodeEncodeError: 'ascii' codec can't encode character '\ufffd' in position 475: ordinal not in range(128)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions