0

I have been trying to solve this for some time. I have a need to output console stuff like:

          ABC-花海 | 123 | 456789
     JustSomeAnsi | 123 | 456789
       花花花花花花 | 123 | 456789
     追不到我别生气 | 123 | 456789

Now I know perfect alignment is not possible, but the example above would be tolerable to me. The question is how would you figure out how much to pad and with what space char.

If context is relevant, this is being output into Unreal Engine console. I've already have replacement for original Roboto font - either Sarasa Gothic or GNU Unifont or just any normal monospaced font like Fira Code + fallback for CJK (DroindSans right now, but it is not monospace)

Digika
  • 127
  • 2
  • 11
  • Please [edit] your question to provide a [mcve]. – JosefZ Jan 06 '23 at 15:06
  • What for? This isn't the code snippet question, i.e. not like I have a specific piece of code that does not work, but rather genera/theoretical approach. – Digika Jan 06 '23 at 15:14
  • Check my last comment under this similar Q: [Need a single width unicode character to indicate a wide character has been shortened for lack of space](https://stackoverflow.com/questions/74715754/) – JosefZ Jan 06 '23 at 16:49

1 Answers1

0

In Unicode, there are fullwidth versions of ASCII characters compatible with CJK in the U+FF00 code point block (See Unicode code chart).

Here is your text using only fullwidth characters, including IDEOGRAPHIC SPACE U+3000:

           ABC-花海 | 123 | 456789
     JustSomeAnsi | 123 | 456789
           花花花花花花 | 123 | 456789
          追不到我别生气 | 123 | 456789

Also see this answer for a related Python-coded example that translates ASCII to the fullwidth forms.

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
  • Thanks, this is useful. Though I realized my input also has bunch of EUR symbols like russian alphabet, etc, some extra symbols and old-style emoji thrown into mix so this now becomes an impossible task. – Digika Jan 06 '23 at 19:08
  • You might want to look at [Unicode Standard Annex #11: East Asian Width](https://www.unicode.org/reports/tr11/). If your content includes a mix of East Asian and European characters, that's a requirement that was supported in East Asian systems since before Unicode, and East Asian fonts would typically have Latin, Greek and Cyrillic characters that were exactly 1/2 the width of East Asian characters, as well as "fullwidth" variants of the European characters on other code points. See UAX #11 and the associated EastAsianWidth.txt data file that's part of the Unicode Standard. – Peter Constable Jan 07 '23 at 22:32