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

Qemu headless curses: charset issues #6332

Closed
easyaspi314 opened this issue Jan 29, 2021 · 8 comments
Closed

Qemu headless curses: charset issues #6332

easyaspi314 opened this issue Jan 29, 2021 · 8 comments
Labels
bug report Something is not working properly.

Comments

@easyaspi314
Copy link
Contributor

easyaspi314 commented Jan 29, 2021

Problem description

I honestly don't know if this is a bug with Termux's terminal, iconv, QEMU, or ncurses.

In qemu-system's curses backend, most low ASCII characters (0x00-0x1f) show up as random CJK characters:

Screenshot_20210129-131307

Steps to reproduce

The thing this most clearly affects is FreeDOS's edit program in color mode. It is 100% unusable.

However, for a standalone BIOS program, unzip the attached file (which has the source code as well for nasm and definitely not a modified Hello World example I found online), and run it like so:

qemu-system-{x86_64/i386} -display curses boot.bin

Either qemu-system-x86_64 or qemu-system-i386 will work, and headless is fine.

This will print bytes 0-255 to the console and hang. Hit Alt+2 and type quit to exit as it tells you to do.
boot.zip

Expected behavior

Something like what the -nographic displays:

Screenshot_20210129-131250

Additional information

Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.org/packages/ stable main
# science-repo (sources.list.d/science.list)
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# game-repo (sources.list.d/game.list)
deb https://dl.bintray.com/grimler/game-packages-24 games stable
# x11-repo (sources.list.d/x11.list)
deb https://dl.bintray.com/xeffyr/x11-packages x11 main
# unstable-repo (sources.list.d/unstable.list)
deb https://dl.bintray.com/xeffyr/unstable-packages unstable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
Updatable packages:
libcairo/stable 1.16.0-7 aarch64 [upgradable from: 1.16.0-2]
pulseaudio/stable 14.2-2 aarch64 [upgradable from: 12.2-21]
Android version:
11
Kernel build information:
Linux localhost 4.4.223-g52750b8f2138-ab6846512 #1 SMP PREEMPT Fri Sep 18 09:49:34 UTC 2020 aarch64 Android
Device manufacturer:
Google
Device model:
Pixel 2 XL

@easyaspi314
Copy link
Contributor Author

I assume it might have something to do with the code here but I haven't tested it.

@ghost
Copy link

ghost commented Jan 29, 2021

That's libiconv I guess. QEMU previously had error "Could not convert font glyphs from UCS-2" but it gone at some version update.

Ctrl-A X doesn't work

Works for me...

@ghost ghost added the bug report Something is not working properly. label Jan 29, 2021
@easyaspi314
Copy link
Contributor Author

easyaspi314 commented Jan 29, 2021

Ctrl-A X doesn't work

Works for me...

Yeah I take it back. It is working now.

It might have been a bad ncurses shutdown blocking keystrokes.

@easyaspi314
Copy link
Contributor Author

easyaspi314 commented Jan 29, 2021

Oh ho ho I found a clue...

Screenshot_20210129-150505

It seems that iconv is trying to convert from UCS-2 big endian.

Why? IDK.

I am going to go boot up WSL and see if this is actually a termux bug, because this is a pretty important discovery.

@easyaspi314
Copy link
Contributor Author

easyaspi314 commented Jan 29, 2021

Nah, it appears to be a Termux issue.

image

QEMU 4.2.1, glibc 2.31, Ubuntu Focal on WSL

However, one thing to note is that it appears that iconv's default for UTF-16 is little endian.

@easyaspi314
Copy link
Contributor Author

If I manually replace UCS-2 with UCS-2LE in ui/curses.c, it works!

Screenshot_20210129-163127

@easyaspi314
Copy link
Contributor Author

So, AFAIK, the issue is that glibc's iconv will treat "UCS-2" as native endianness, while libiconv will treat it as big endian. What a blatant inconsistency.

ghost pushed a commit that referenced this issue Jan 29, 2021
@ghost
Copy link

ghost commented Jan 31, 2021

I guess this issue can be closed now. Package is now patched and seems working correctly.

@ghost ghost closed this as completed Jan 31, 2021
@ghost ghost locked and limited conversation to collaborators Oct 9, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug report Something is not working properly.
Projects
None yet
Development

No branches or pull requests

1 participant