Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode Bangla text not rendering properly in Windows Terminal console #18571

Open
memamun opened this issue Feb 13, 2025 · 3 comments
Open

Unicode Bangla text not rendering properly in Windows Terminal console #18571

memamun opened this issue Feb 13, 2025 · 3 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@memamun
Copy link

memamun commented Feb 13, 2025

Windows Terminal version

1.21.10351.0

Windows build number

10.0.19045.0

Other Software

PowerShell 7.4.6

Steps to reproduce

Steps to reproduce

  1. Downlaod or copy the json to a file news.json with UTF-8 encoding containing Bangla text (see code snippet below).
  2. Open Windows Terminal (PowerShell)
  3. Set output encoding to UTF-8: $OutputEncoding = [System.Text.Encoding]::UTF8
  4. Run: Get-Content -Path .\news.json -Raw | ConvertFrom-Json
  5. Observe incorrect Bangla rendering in the output.

Download the File: news.json

[
    {
        "title": "সাগর-রুনি হত্যা: নিরাপত্তাকর্মীকে কারা ফটকে জিজ্ঞাসাবাদ",
        "link": "https://www.prothomalo.com/bangladesh/ksfmm5h342"
    },
    {
        "title": "বছরে আয় ৩১৫০ কোটি টাকা, আবারও বিশ্বের সবচেয়ে বেশি আয়ের অ্যাথলেট ক্রিস্টিয়ানো রোনালদো",
        "link": "https://www.prothomalo.com/sports/football/b4uf56g5y6"
    },
    {
        "title": "মোটরযানের গতিসীমা নির্দেশিকার বাস্তবায়ন চায় রোড সেফটি কোয়ালিশন",
        "link": "https://www.prothomalo.com/bangladesh/r9lmm4kczo"
    },
    {
        "title": "জাতিসংঘের প্রতিবেদন ট্রাইব্যুনালে অকাট্য দলিল হিসেবে ব্যবহার করা যাবে: চিফ প্রসিকিউটর",
        "link": "https://www.prothomalo.com/bangladesh/zu65htd5rd"
    },
    {
        "title": "৫ আগস্টের ‘মার্চ অন ঢাকা’ ঠেকাতে যেভাবে পরিকল্পনা করেছিল হাসিনা সরকার",
        "link": "https://www.prothomalo.com/bangladesh/f8x2ud35t3"
    },
    {
        "title": "শান্ত-মারিয়াম ফাউন্ডেশন ডে উদ্‌যাপন",
        "link": "https://www.prothomalo.com/education/campus/y2e1oqab76"
    },
    {
        "title": "যুক্তরাষ্ট্রের জাতীয় গোয়েন্দা প্রধান হলেন তুলসী গ্যাবার্ড",
        "link": "https://www.prothomalo.com/video/international/55zuoow5co"
    },
    {
        "title": "ন্যূনতম সংস্কার কর্মসূচির একটি নকশা",
        "link": "https://www.prothomalo.com/opinion/column/hdmqrmrbm3"
    },
    {
        "title": "ধামরাইয়ে বিনোদনকেন্দ্রের কর্মীদের সঙ্গে শিক্ষার্থীদের সংঘর্ষের ঘটনায় মামলা",
        "link": "https://www.prothomalo.com/bangladesh/district/azghc2wcg3"
    },
    {
        "title": "মাকে নিয়ে মজার ঘটনা",
        "link": "https://www.prothomalo.com/other/ks01wwijtp"
    },
    {
        "title": "জাহাঙ্গীরনগরে সি ইউনিটের ভর্তি পরীক্ষা শুরু, আসনপ্রতি পরীক্ষার্থী ১২১",
        "link": "https://www.prothomalo.com/education/examination/fac92k5hwq"
    },
    {
        "title": "জাতীয় ঐকমত্য কমিশন গঠন, সভাপতি অধ্যাপক ইউনূস",
        "link": "https://www.prothomalo.com/bangladesh/o8jo54zlmv"
    },
    {
        "title": "কন্যাসন্তান নিয়ে বিতর্কিত মন্তব্য করে বিপদে চিরঞ্জীবী",
        "link": "https://www.prothomalo.com/entertainment/bollywood/344j4pvcez"
    },
    {
        "title": "লোকজ উৎসবে নারায়ণগঞ্জ বন্ধুসভার মূকাভিনয় প্রদর্শন",
        "link": "https://www.prothomalo.com/activities/nnz22sg2r9"
    },
    {
        "title": "গাজীপুরে কাশেমের জানাজায় আওয়ামী লীগ নিষিদ্ধের দাবি",
        "link": "https://www.prothomalo.com/bangladesh/district/3dna5uwiap"
    },
    {
        "title": "বসন্তের আমেজে ফুলে ফুলে তারকারা",
        "link": "https://www.prothomalo.com/celeb/look/8scw6wllfs"
    },
    {
        "title": "সংস্কার ছাড়া নির্বাচন নয়: জামায়াতে ইসলামী",
        "link": "https://www.prothomalo.com/politics/lnvdeecjtk"
    },
    {
        "title": "মহারাষ্ট্রের সাবেক মন্ত্রীর ব্যাংককগামী ছেলেকে ঘিরে মাঝ আকাশে নাটকীয়তা",
        "link": "https://www.prothomalo.com/world/india/6sz6q4ln4r"
    },
    {
        "title": "আজকের বিনিময় হার",
        "link": "https://www.prothomalo.com/business/sx6znkk8sk"
    },
    {
        "title": "ডিস্ক প্রলাপস কেন হয়, সতর্কতা ও চিকিৎসা কী",
        "link": "https://www.prothomalo.com/lifestyle/health/0g2c16pw8n"
    }
]

Expected Behavior

Bangla characters should render correctly, as they do in text editors or web browsers using the same font.

Actual Behavior

Image

Bangla characters are garbled (see screenshot attached).

Description of the issue:

Bengali characters are not rendering correctly in Windows Terminal when displaying any Bengali text output on windows terminal.

I have tried Setting $OutputEncoding to UTF-8 and changing different font but not working.
Please see the attached screenshot for reference.

Please fix this issue. We(Bangladeshi) need this in the moth of Language (February).

I appreciate your effort to fix the bug. Thank you.

@memamun memamun added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 13, 2025
@o-sdn-o
Copy link

o-sdn-o commented Feb 13, 2025

It seems to me that this is hardly possible without special tailoring of text data and using a terminal emulator that supports such tailoring. Since it is not yet possible to create a monospace font for abugida scripts like Devanagari/Bengali/etc.

By "tailoring" I mean placing character geometry modifiers inside the source text in order to specify explicit sizes of grapheme clusters to the terminal. See Unicode Character Geometry Modifiers for details.

Here is an example of "tailored" news2.json:
[
    {
        "title": "�সাগর-রুনি󐁉 �হত্যা󐀳: �নিরাপত্তাকর্মীকে󐁑 �কারা󐀳 �ফটকে󐀷 �জিজ্ঞাসাবাদ󐁉",
        "link": "https://www.prothomalo.com/bangladesh/ksfmm5h342"
    },
    {
        "title": "�বছরে󐀷 �আয়󐀳 �৩১৫০󐀷 �কোটি󐀷 �টাকা󐀳, �আবারও󐀼 �বিশ্বের󐀷 �সবচেয়ে󐀼 �বেশি󐀳 �আয়ের󐀷 �অ্যাথলেট󐁂 �ক্রিস্টিয়ানো󐁉 �রোনালদো󐁂",
        "link": "https://www.prothomalo.com/sports/football/b4uf56g5y6"
    },
    {
        "title": "�মোটরযানের󐁉 �গতিসীমা󐀼 �নির্দেশিকার󐁉 �বাস্তবায়ন󐁂 �চায়󐀰 �রোড󐀳 �সেফটি󐀷 �কোয়ালিশন󐁉",
        "link": "https://www.prothomalo.com/bangladesh/r9lmm4kczo"
    },
    {
        "title": "�জাতিসংঘের󐁉 �প্রতিবেদন󐁂 �ট্রাইব্যুনালে󐁉 �অকাট্য󐀼 �দলিল󐀷 �হিসেবে󐀷 �ব্যবহার󐀷 �করা󐀳 �যাবে󐀳: �চিফ󐀳 �প্রসিকিউটর󐁉",
        "link": "https://www.prothomalo.com/bangladesh/zu65htd5rd"
    },
    {
        "title": "৫ �আগস্টের󐁂 ‘�মার্চ󐀰 �অন󐀳 �ঢাকা󐀳’ �ঠেকাতে󐀼 �যেভাবে󐀼 �পরিকল্পনা󐁂 �করেছিল󐀼 �হাসিনা󐀷 �সরকার󐀷",
        "link": "https://www.prothomalo.com/bangladesh/f8x2ud35t3"
    },
    {
        "title": "�শান্ত-মারিয়াম󐁑 �ফাউন্ডেশন󐁉 �ডে󐀰 �উদ্‌যাপন󐀼",
        "link": "https://www.prothomalo.com/education/campus/y2e1oqab76"
    },
    {
        "title": "�যুক্তরাষ্ট্রের󐁂 �জাতীয়󐀷 �গোয়েন্দা󐀼 �প্রধান󐀷 �হলেন󐀷 �তুলসী󐀷 �গ্যাবার্ড󐀷",
        "link": "https://www.prothomalo.com/video/international/55zuoow5co"
    },
    {
        "title": "�ন্যূনতম󐀼 �সংস্কার󐀷 �কর্মসূচির󐀼 �একটি󐀷 �নকশা󐀷",
        "link": "https://www.prothomalo.com/opinion/column/hdmqrmrbm3"
    },
    {
        "title": "�ধামরাইয়ে󐁂 �বিনোদনকেন্দ্রের󐁑 �কর্মীদের󐀼 �সঙ্গে󐀳 �শিক্ষার্থীদের󐁉 �সংঘর্ষের󐀼 �ঘটনায়󐀷 �মামলা󐀷",
        "link": "https://www.prothomalo.com/bangladesh/district/azghc2wcg3"
    },
    {
        "title": "�মাকে󐀳 �নিয়ে󐀳 �মজার󐀷 �ঘটনা󐀳",
        "link": "https://www.prothomalo.com/other/ks01wwijtp"
    },
    {
        "title": "�জাহাঙ্গীরনগরে󐁑 �সি󐀰 �ইউনিটের󐁂 �ভর্তি󐀳 �পরীক্ষা󐀷 �শুরু󐀳, �আসনপ্রতি󐁂 �পরীক্ষার্থী󐀼 �১২১󐀰",
        "link": "https://www.prothomalo.com/education/examination/fac92k5hwq"
    },
    {
        "title": "�জাতীয়󐀷 �ঐকমত্য󐀼 �কমিশন󐀼 �গঠন󐀳, �সভাপতি󐀼 �অধ্যাপক󐀼 �ইউনূস󐀷",
        "link": "https://www.prothomalo.com/bangladesh/o8jo54zlmv"
    },
    {
        "title": "�কন্যাসন্তান󐁉 �নিয়ে󐀳 �বিতর্কিত󐀼 �মন্তব্য󐀷 �করে󐀳 �বিপদে󐀷 �চিরঞ্জীবী󐀼",
        "link": "https://www.prothomalo.com/entertainment/bollywood/344j4pvcez"
    },
    {
        "title": "�লোকজ󐀼 �উৎসবে󐀼 �নারায়ণগঞ্জ󐁉 �বন্ধুসভার󐀼 �মূকাভিনয়󐁂 �প্রদর্শন󐀷",
        "link": "https://www.prothomalo.com/activities/nnz22sg2r9"
    },
    {
        "title": "�গাজীপুরে󐁂 �কাশেমের󐁂 �জানাজায়󐁂 �আওয়ামী󐁂 �লীগ󐀳 �নিষিদ্ধের󐀼 �দাবি󐀳",
        "link": "https://www.prothomalo.com/bangladesh/district/3dna5uwiap"
    },
    {
        "title": "�বসন্তের󐀼 �আমেজে󐀼 �ফুলে󐀳 �ফুলে󐀳 �তারকারা󐀼",
        "link": "https://www.prothomalo.com/celeb/look/8scw6wllfs"
    },
    {
        "title": "�সংস্কার󐀷 �ছাড়া󐀳 �নির্বাচন󐀷 �নয়󐀰: �জামায়াতে󐁂 �ইসলামী󐀼",
        "link": "https://www.prothomalo.com/politics/lnvdeecjtk"
    },
    {
        "title": "�মহারাষ্ট্রের󐁂 �সাবেক󐀷 �মন্ত্রীর󐀳 �ব্যাংককগামী󐁉 �ছেলেকে󐀼 �ঘিরে󐀳 �মাঝ󐀳 �আকাশে󐀼 �নাটকীয়তা󐁂",
        "link": "https://www.prothomalo.com/world/india/6sz6q4ln4r"
    },
    {
        "title": "�আজকের󐁂 �বিনিময়󐀼 �হার󐀰",
        "link": "https://www.prothomalo.com/business/sx6znkk8sk"
    },
    {
        "title": "�ডিস্ক󐀳 �প্রলাপস󐀼 �কেন󐀳 �হয়󐀰, �সতর্কতা󐀼 ও �চিকিৎসা󐀼 �কী󐀰",
        "link": "https://www.prothomalo.com/lifestyle/health/0g2c16pw8n"
    }
]

Here is the output result:

pwsh.2025-02-13.18-04-58.mp4

Note, WT doesn't currently support output this way, maybe this example will enlighten someone to a better approach. For now it only works in vtm.

Key Unicode codepoints:

Name Codepoint Description
STX 0x02 Grapheme cluster start
vss<11> 0xd002e Set cluster size to 1x1
vss<21> 0xd0030 Set cluster size to 2x1
vss<31> 0xd0033 Set cluster size to 3x1
vss<41> 0xd0037 Set cluster size to 4x1
vss<51> 0xd003c Set cluster size to 5x1
vss<61> 0xd0042 Set cluster size to 6x1
vss<71> 0xd0049 Set cluster size to 7x1
vss<81> 0xd0051 Set cluster size to 8x1

Samples for powershell:

"`u{2}টার্মিনাল`u{d003c}"
"`u{2}এমুলেটর`u{d0049}"

It is also worth noting that Write-Output in powershell incorrectly calculates the length of such lines:

Image

@lhecker
Copy link
Member

lhecker commented Feb 13, 2025

@memamun Can you please first update to the latest version 1.22? It has a new Unicode implementation. If the update is not showing up for you, you can download it directly here: https://github.com/microsoft/terminal/releases/download/v1.22.10352.0/Microsoft.WindowsTerminal_1.22.10352.0_8wekyb3d8bbwe.msixbundle

You'll notice that it works, because it'll break PowerShell:

Image

...but that's a PowerShell bug, because they don't support grapheme clusters.

@memamun
Copy link
Author

memamun commented Feb 13, 2025

I have updated to the latest version you provided. Seems better but not showing perfectly. May be the Bengali language is not supported by Powershell or Windows Terminal yet.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants