← Journal

offSchool engineering · November 8, 2026

Fixing Bijoy to Unicode: 17,000 Broken Bangla Words

Bangla PDFs typed in SutonnyMJ store Bijoy codes, not Unicode. Converting the NCTB curriculum PDFs for offSchool left about 17,000 garbled words. Three codes and one syllable rule caused nearly all of them.

By Shihab Shahriar Antor · Updated 2026-11-08

Why offSchool needed this text

offSchool teaches the class 9 and 10 (SSC) science syllabus of Bangladesh, and every lesson has to match what the National Curriculum and Textbook Board (NCTB) asks for. The board's curriculum documents list each chapter's learning outcomes (শিখনফল) beside its content (বিষয়বস্তু). offSchool extracts them to check its 683 topics against the syllabus and to guide how each chapter is written.

The PDFs have a real text layer, which looks like good news until you read it. The Bangla in them was typed in SutonnyMJ, a Bijoy font. Bijoy predates Unicode Bangla: the file stores the codes of an English keyboard layout, and the font draws Bangla shapes over them. Copy the subject name পদার্থবিজ্ঞান out of one of these PDFs and you get c`v_©weÁvb.

How the conversion works

The extractor reads every text span with PyMuPDF and checks its font. Spans in SutonnyMJ, KalindiMJ or ChandrabatiMJ go through bijoy2unicode. Spans in Arial, Times or Vrinda are already Unicode and pass through untouched, which matters because English terms sit in the middle of Bangla sentences. Symbol-font spans (Greek letters, arrows, ≤ and ≥) go through a small table of their own.

The first run produced readable text with a steady rash of wrong words. Counted across the curriculum text, the SSC and HSC chapter files and the normalized syllabus, there were about 17,000 of them. They were not random. Almost all came from four causes.

What broke, and the fix for each
CauseWhat came outShould readFix
The code ø is the ল-phala (্ল) in this older SutonnyMJ, but the library reads it as স্নসংশিস্নষ্ট, অম্স্নসংশ্লিষ্ট, অম্লMap ø to the library's own ্ল code before converting
The code Ð is ণ্ড here, always inside a word, but the library reads it as a dashকা-, বায়ুম-লকাণ্ড, বায়ুমণ্ডলMap Ð to the library's ণ্ড code; Ñ really is a dash and stays one
A reph (র্) ends its syllable, but the library converts straight across it and hands the next pre-kar to the wrong consonantশিক্ষার্থীেদর, পর্যােলাচনাশিক্ষার্থীদের, পর্যালোচনাSplit the Bijoy text after the reph and any vowel signs that follow it, and convert each side on its own
A pre-kar (ি, ে) typed in its own span, often in a different weight, is converted aloneিভত্তিক, lost spacesভিত্তিকJoin touching Bangla spans and convert them together

The reph rule alone accounted for about 14,000 of the 17,000. A fifth code, ÿ, is a ক্ষ variant the library does not know, and two older glyph pairs (্ত্ম for ্ত and রম্ন for রু) are fixed after conversion.

Why the reph breaks things

In Bijoy, a vowel sign that is drawn on the left, such as ি or ে, is typed before its consonant, the way it looks. Unicode stores it after the consonant, the way it is said. So a converter has to move each pre-kar across exactly one consonant cluster. The reph, a র্ written as a hook above the next letter, is typed after its cluster in Bijoy too. When the library met a reph followed by a vowel sign and then the next syllable's pre-kar, it lost track of where one syllable ended, and the ে of দের ended up after the wrong letter.

The fix is a regular expression on the Bijoy text before conversion: end the piece after the reph code © and any trailing post-kars, when a pre-kar comes next. Each piece then converts correctly on its own, and a second pass moves the reph to the front of its cluster, where Unicode wants it.

The source has typos too

Not every wrong word is the converter's fault. The PDFs carry the typesetter's own slips: a doubled vowel sign, হ্নদপিণ্ড for হৃদপিণ্ড, প্লাকং for প্লাঙ্ক in Max Planck's name, and one ণ্ড typed as a dash in লঞ্চ বা স্টিমার. No glyph rule can fix a word that was typed wrong, so these live in a short word list of three dozen entries, matched after NFC normalization.

Some printed spellings were kept on purpose. Loanwords such as সিলিণ্ডার use a separate ন্ড glyph in the font, and দূর্যোগ is how the document prints it. Each of those calls went to three independent checks and followed the majority. A converter that silently "corrects" the source is no longer a faithful copy of it.

Normalization is part of the fix

Unicode allows more than one byte sequence for some Bangla letters. ো can be stored as ে followed by া, or as the single code point U+09CB, and য় can be one code point or য plus a nukta. Text that looks identical can therefore fail to match. Every comparison here runs on NFC, the converter composes ে plus া into ো, and the word list is keyed on NFC so a fix cannot miss its target because of an invisible difference.

How the fix was checked
  1. 01

    Re-extract everything

    Every PDF was converted again from the raw files with the new rules, rather than patching the old output by hand.

  2. 02

    Diff, then map

    Old and new text were aligned line by line. Where the old files could not simply be replaced, a word map derived from that diff was applied to them instead.

  3. 03

    Cross-check three ways

    The old text with the map applied had to equal the fresh extraction, the SSC chapter files had to equal a rebuild from their source, and the count of syllabus lines the checker could not find had to stay where it was.

  4. 04

    Review the Bangla

    Every word that was kept as printed or changed by hand went to three independent checks, and the majority decided.

  5. 05

    Ship and reseed

    The change merged on November 1, 2026 and production was reseeded the same day: 59 chapters, 683 topics and 659 learning outcomes.

A validator so it cannot come back

The last step was the one that matters a year from now. offSchool's content check, which runs on every change to the curriculum, simulations and practice questions, now rejects any Bangla word that a broken conversion would produce:

  • a word that starts with a vowel sign;
  • two vowel signs in a row;
  • a vowel sign straight after a hasanta (্);
  • two hasantas in a row;
  • স্ন anywhere but the start of a word, which is the garbled ্ল.

None of these occurs in correctly typed Bangla, so the check has no false alarms to tune away. Before the fix, the existing content failed it 76 times. One implementation detail is worth knowing: a JavaScript regular-expression character class that mixes consonants and vowel signs trips ESLint's no-misleading-character-class rule, so the patterns are built as alternations with new RegExp.

What students saw

Less than the numbers suggest. Most of the garbling sat in source and reference files that students never read. In the syllabus data the app actually serves, 78 strings changed, nearly all of them chapter guidance used only behind the scenes, and two learning outcomes got their missing spaces back. No chapter or topic title changed. The lesson is about where the damage would have gone next: every new note, question and search index built from that text would have inherited it.

If you are converting Bijoy PDFs yourself

Check which font each span uses and convert only the Bijoy ones. Find out which version of the font your documents use, because older SutonnyMJ assigns some codes differently from what converters expect. Split at the reph before converting, convert touching Bangla spans together, normalize to NFC, and finish with a garble check like the one above. Then read a sample of the output yourself, because a pattern check cannot tell you that a correctly formed word is the wrong word.

Questions

What is Bijoy encoding?
Bijoy is a Bangla keyboard layout and font family, such as SutonnyMJ, that predates Unicode Bangla. Text typed in it is stored as the codes of an English keyboard, and the font draws Bangla shapes over them, so copying it out of a PDF gives Latin characters like c`v_©weÁvb instead of পদার্থবিজ্ঞান.
Why does Bangla text copied from a PDF look broken?
Usually because the PDF was typed in a Bijoy font, so its text layer holds keyboard codes, not Unicode. Converting it with a Bijoy-to-Unicode tool fixes most words, but codes that differ between font versions and vowel signs placed around a reph can still come out wrong.
Can bijoy2unicode convert SutonnyMJ PDFs?
Yes, for most text. With the older SutonnyMJ in the 2012 NCTB curriculum PDFs it needed three codes mapped first (ø as ল-phala, Ð as ণ্ড, ÿ as a ক্ষ variant), the text split after each reph, and touching spans converted together.
How can garbled Bangla be detected automatically?
Check each word after NFC normalization for shapes correct Bangla never has: a word starting with a vowel sign, two vowel signs or two hasantas in a row, a vowel sign after a hasanta, and স্ন inside a word. Each is a symptom of a broken conversion.
Did this affect offSchool's lessons?
Very little. The garbled words sat mostly in source and reference files. In the syllabus data the app serves, 78 strings changed, almost all behind-the-scenes chapter guidance, and no chapter or topic title changed. The fix stops the errors spreading into anything built from that text later.