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)

asked Jan 6, 2023 at 14:55
3

1 Answer 1

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.

answered Jan 6, 2023 at 17:43
Sign up to request clarification or add additional context in comments.

2 Comments

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.
You might want to look at Unicode Standard Annex #11: East Asian Width. 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.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.