Bug 500515

Summary: [export/html] html output has random glyph, not looking like what I have in Konsole
Product: [Applications] konsole Reporter: David REVOY <info>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 22.12.3   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description David REVOY 2025-02-21 11:35:00 UTC
Hi,

I love exporting terminal output of konsole as html but the result is always broken as soon as a special character is part of the output.

## How to reproduce

1. Open Konsole
2. Write command lines that output special characters (eg. 'tree' is good for that)
3. Export the output as HTML (File → Save Output As and select an html file format).
4. Host your HTML file, and open it in Firefox.

## Result: 

The special characters are corrupted, and random glyph appears. Example:
https://peppercarrot.com/extras/forum/2025-02-21_konsole-default-html-output.html
( screenshot: https://peppercarrot.com/extras/forum/2025-02-21_screenshot_122028_net.jpg )

## Expectation

It should looks like what I had in konsole, like that: https://peppercarrot.com/extras/forum/2025-02-21_screenshot_123118_net.jpg

## Workaround

I saw the html output file don't have any header, or set any charsets.  If one manually edit the html output file with Kate, and insert at the start of the file:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
```

Then the output will be readable again. Here is an example: 
https://peppercarrot.com/extras/forum/2025-02-21_konsole-default-html-output_FIXED.html

Too bad this workaround is tedious to do over and over again, I would appreciate an automatic way to get this (or another fix) to read and transmit my HTML output correctly. Thank you.
Comment 1 Kurt Hindenburg 2025-02-22 16:15:56 UTC
The page looks OK in Brave and Firefox here.  I wonder if it font related. I don't recall why we don't add the DOCTYPE.  I'll look at it.
Comment 2 Bug Janitor Service 2025-03-30 16:27:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/1089
Comment 3 Christoph Cullmann 2025-04-13 12:38:14 UTC
Git commit 7ef31a797717bf1a86304f8aa18c68ace85d7afe by Christoph Cullmann.
Committed on 13/04/2025 at 12:22.
Pushed by cullmann into branch 'master'.

wrap output it html document & body

ensure right encoding is set

M  +8    -0    src/autotests/TerminalCharacterDecoderTest.cpp
M  +13   -0    src/decoders/HTMLDecoder.cpp

https://invent.kde.org/utilities/konsole/-/commit/7ef31a797717bf1a86304f8aa18c68ace85d7afe
Comment 4 David REVOY 2025-04-13 12:54:42 UTC
Thank you very much!