Skip to content

fix(teletext): Add --ttxtforcelatin option to force Latin G0 charset - #1821

Merged
cfsmp3 merged 1 commit into
masterfrom
fix/issue-1395-teletext-latin-charset
Dec 14, 2025
Merged

cfsmp3 merged 1 commit into
masterfrom
fix/issue-1395-teletext-latin-charset

Conversation

@cfsmp3

@cfsmp3 cfsmp3 commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Added new --ttxtforcelatin command-line option
  • Forces teletext G0 character set to Latin, ignoring Cyrillic designations in the stream
  • Fixes garbled output where Latin text appears as Cyrillic characters

Problem

Some broadcast streams (e.g., UK Freesat recordings) incorrectly signal Cyrillic character set via X/28 or M/29 teletext packets when the actual content is Latin English text.

Before (garbled Cyrillic):

Но. Нот бацк тхен, анiваi.

Expected (correct Latin):

No. Not back then, anyway.

Root Cause

The broadcast stream contains triplet value 0x1290 which has:

  • Bits 10-13 = 0x1 (Cyrillic character set family per ETS 300 706 Table 32)
  • Bits 7-9 = 0x5 (Ukrainian option)

This causes CCExtractor to select CYRILLIC3 (Ukrainian) charset instead of Latin.

Solution

Added --ttxtforcelatin option that bypasses the Cyrillic character set detection and always uses Latin G0 charset.

Changes

  • src/lib_ccx/lib_ccx.h: Added forceg0latin field to teletext config
  • src/lib_ccx/telxcc.c: Modified set_g0_charset() to respect forceg0latin option
  • src/rust/src/args.rs: Added --ttxtforcelatin CLI argument
  • src/rust/src/parser.rs: Added argument handling
  • src/rust/src/common.rs: Added field to struct conversion
  • src/rust/lib_ccxr/src/teletext.rs: Added forceg0latin to TeletextConfig

Test plan

Usage

ccextractor input.ts --ttxtforcelatin -o output.srt

Fixes #1395

🤖 Generated with Claude Code

Some broadcast streams incorrectly signal Cyrillic character set (via
X/28 or M/29 packets) when the actual content is Latin text. This causes
garbled output where Latin text like "No. Not back then, anyway." appears
as Cyrillic "Но. Нот бацк тхен, анiваi."

This fix adds a new --ttxtforcelatin option that forces the teletext G0
character set to Latin, ignoring any Cyrillic designation in the stream.

Root cause: The broadcast contained triplet 0x1290 which has bits 10-13
set to 0x1 (Cyrillic family) and bits 7-9 set to 0x5 (Ukrainian option),
causing CCExtractor to use CYRILLIC3 charset instead of Latin.

Usage: ccextractor input.ts --ttxtforcelatin -o output.srt

Before fix (without option):
  Subtitle 3: Но. Нот бацк тхен, анiваi.

After fix (with --ttxtforcelatin):
  Subtitle 3: No. Not back then, anyway.

Fixes #1395

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@cfsmp3
cfsmp3 merged commit d2ab31f into master Dec 14, 2025
@cfsmp3
cfsmp3 deleted the fix/issue-1395-teletext-latin-charset branch December 19, 2025 06:03
Deepak-negi11 added a commit to Deepak-negi11/ccextractor that referenced this pull request Oct 18, 2026
The Rust port of telxcc.c (lib_ccxr/src/teletext.rs) is not called yet,
and as it stands it could never produce output:
- receiving_data was never set to true (C sets it at telxcc.c:1072), so
  every row packet was dropped
- the parity check was inverted, so every valid character became a space
- the line trimming loop from telxcc.c:690-701 was missing, so col_stop
  stayed 40 and text[row][40] panicked
- a non-BCD page number (e.g. 0x7a0) indexed seen_sub_page[1000] out of
  bounds; read the leading digits like C's atoi()
- close() dropped the last buffered page instead of outputting it

Also bring over later telxcc.c changes: hide a page when the next one
starts (CCExtractor#2292), honour --ttxtforcelatin (CCExtractor#1821), only print the page
notice with file reports, decode Hamming 8/4 errors as 0x0f like
unham_8_4(), and treat a Levenshtein distance equal to the limit as a
match like fuzzy_memcmp(). Multi-page extraction is left out: CCExtractor#2356 is
changing that logic in telxcc.c.
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.

[QUESTION] Setting to translate Cyrillic to Latin

1 participant