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

Non-BMP code points don't work on Linux #2615

Open
tig opened this issue May 9, 2023 · 2 comments
Open

Non-BMP code points don't work on Linux #2615

tig opened this issue May 9, 2023 · 2 comments

Comments

@tig
Copy link
Collaborator

tig commented May 9, 2023

Unicode issue related to: #2610

See also: #2616

Try as I might, I can't seem to get the CursesDriver to output non-BMP code points.

NetDriver works well:

image

I've gone as far code like this:

					if (rune.IsBmp) {
						Contents [Row, Col, 0] = rune.Value;
						Curses.addch (Contents [Row, Col, 0]);
					} else {
						var column = Col;
						ReadOnlySpan<char> remainingInput = rune.ToString ().AsSpan ();
						while (!remainingInput.IsEmpty) {
							// Decode
							OperationStatus opStatus = Rune.DecodeFromUtf16 (remainingInput, out Rune result, out int charsConsumed);

							if (opStatus != OperationStatus.Done) {
								result = Rune.ReplacementChar;
							}
							Contents [Row, column, 0] = result.Value;
							Contents [Row, column, 1] = CurrentAttribute;
							
							Curses.attrset (Contents [Row, column, 1]);
							Curses.mvaddch (Row, column, Contents [Row, column, 0]);

							// Slice and loop again
							remainingInput = remainingInput.Slice (charsConsumed);
							column++;
						}
						Curses.move (Row, Col);
					}
					Curses.attrset (curAttr);
				}

CursesDriver results in this:

image

@BDisp
Copy link
Collaborator

BDisp commented May 9, 2023

You are in the right way, good catch. I'm working on a new PR that get rid the NStack dependence that fix #92. What you are relating here for a long time I already realized the same.

@tig
Copy link
Collaborator Author

tig commented May 9, 2023

You are in the right way, good catch. I'm working on a new PR that get rid the NStack dependence that fix #92. What you are relating here for a long time I already realized the same.

Uh-ohl I started the same thing today. I've made huge progress, starting just with ConsoleDriver and subclasses.

I'll push my PR and you can see what I've done....

@tig tig changed the title non-BMP code points don't work on Linux Non-BMP code points don't work on Linux Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants