question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change the glyphs type from Rune to string.

See original GitHub issue
          > > One thing come on mind is to change all glyphs to string. This will be more easy to manipulate with text. What do you think?

I only asked because some glyphs may be set with more than one code point, like the Man, Woman and Girl emoji 👨‍👩‍👧, which is presented with "\U0001F468\u200D\U0001F469\u200D\U0001F467" string and cannot be displayed with only one code point.

Good call. Please open an issue and I’ll do that!

_Originally posted by @tig in https://github.com/gui-cs/Terminal.Gui/issues/2620#issuecomment-1546813406_

@tig for surrogate pairs code points please use the encoded code point e.g. Man 👨 or "\U0001F468", instead of the decoded two surrogate pairs ("\ud83d\udc68").

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
BDispcommented, May 20, 2023

The RuneJsonConverter must check if a rune with two surrogates has a valid surrogate pair, which has a valid high surrogate and a valid low surrogate, otherwise shouldn’t accept it. A alone high surrogate or a alone low surrogate aren’t accepted. If a rune is composed by various non surrogate it may be a valid string, or if it’s composed by valid surrogate pairs and with non surrogate, it may be a valid string.

1reaction
tigcommented, May 19, 2023

After first Rune -> string in GlyphDefinitions and realizing this makes USING the glyphs awkward (Rune x = CM.Checked.ToRunes() [0] or similar alternatives), I think the right thing to do is leave GlyphDefinitions to continue to use Rune as the property type, but enhance RuneJsonConverter to support specifying as a string with a low and high surrogate (or any # of them).

This will all be valid:

    "Checked":  '☑',
    "Checked":  "☑",
    "Checked":   "/u2611",
    "Checked":   "U+2611",
    "Checked":   '/u2611',
    "Checked": 9745,
    "Man": "👨",
    "Man":  "\U0001F468",
    "Man": "\ud83d\udc68",
    "Man": "\U+1F468",

I will introduce both unit tests and exceptions if a property in GlyphDefinitions cannot be normlized to a single rune (using Rune.TryCreate). These will fail:

    "Checked":  '☑☑',
    "Checked":  "☑☑",
    "Checked":   "/u2611/u2611",
    "TooManyMen":  "\U0001F468\U0001F468",
    "HighSurrogate": "\ud83d"

Note, technically, backticks (') are not valid JSON for specifying strings. But most JSON parsers including System.Text.Json let it happen. We cannot detect what the input is.

etc…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Golang converting from rune to string
If you just want to convert a single rune to string , use a simple type conversion. rune is alias for int32 ,...
Read more >
Convert between rune array/slice and string
When you convert a slice of runes to a string, you get a new string that is the concatenation of the runes converted...
Read more >
How to Convert Rune to String in Golang - AskGolang
To convert a rune to a string, you can use the "string()" function. In Go, a rune is an alias for the int32...
Read more >
Golang Program to Convert Character to String
This function takes the rune value as an input and converts it to return the output as a string.
Read more >
Stupid Simple Question about strings and runes : r/golang
the compiler keeps yelling at me for the if statement that it cannot convert "(" (type untyped string) to type rune.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found