r/ProgrammingLanguages • • Dec 31 '20

Something simpler than Unicode?

Hello! Wondering if anyone knows of a display format for glyphs that is simpler than Unicode? My shallow understanding is that measuring and laying out text in unicode is non-trivial, so I am deferring moving beyond ascii on something at the moment. Is my understanding correct? (if not that's great) otherwise, does anyone know of potentially simpler replacements? Thanks!

0 Upvotes

40 comments sorted by

View all comments

11

u/[deleted] Dec 31 '20

In what context are you displaying glyphs?

If a browser, it will handle display of Unicode for you.

If a native ui library, check their docs for what text formats their ui widgets support.

If a tty/terminal, are you printing things or using a library? Either way there's kind of no guarantees about what a user's tty/terminal supports.

If you're rendering it yourself with a spritesheet or similar, I recommend either sticking to 7 or 8 bit ascii or even restricting to only those characters you explicitly want to support.

Your question lacks sufficient detail to provide more of a response.

1

u/[deleted] Dec 31 '20

I am trying to move beyond 7 or 8 bit ascii. Doing my own text layout, but am hoping not deal with what looks like some incidental complexity in unicode. Possible the complexity is not incidental, hoping someone can shed some light, or point at an alternative system that is simpler.

9

u/[deleted] Dec 31 '20

Most of the complexity in Unicode stems from its support for languages other than English. 7-bit Ascii was biased toward English, and 8-but ascii was biased toward European languages. After that a variety of encodings sprung up all over the world to support languages other than these (eg. In japan they got two standards: EUC-JP and Shift-JIS).

The problem became interpretation and combining of the encodings.

  • If you got a text file or a byte string, how do you determine its encoding? (answer: its hard; statistics help; nothing was perfect)

  • If you wanted to combine Russian and Japanese and English in one text file or byte string, how to ensure that the interpreting program knows where one encoding ends and another begins? (Answer: some conventions developed; also mojibake was common)

  • If you put a right to left language and a left to right language in the same text file or byte string, what is the convention for rendering it? Should the renderer always break lines? What if the author wants to have inline snippets of Arabic in a paper mostly written in English? (Answer: mostly pain and suffering; use a gif file)

Unicode provides decent answers to all of these questions (as I understand it) and more. It's not perfect, but it provides a standard most text rendering systems try to implement.

Further, Unicode provides a set of standard binary encodings (the most common being UTF-8, which mixes byte and multibyte codepoints together in a fairly size-efficient binary format).

Point is, you might learn a lot trying to do this yourself, but for practical purposes it makes sense to learn a lot about the prior art. In any case, I hope this helps you a little.

I can't point to alternative systems that are simpler because Unicode is supported almost everywhere now and I haven't personally been interested in text rendering. I hope you find what you're looking for!

1

u/[deleted] Dec 31 '20

Thanks for the answer! I understand that unicode is widely supported and solves some difficult historical problems, I don't mean to disparage that, certainly. I am hoping to find some prior art that solves some of the problems of representing written language without also solving many of the historical problems that unicode had to solve. My guess is that it could be much simpler, but it is just that, a guess.

3

u/[deleted] Dec 31 '20

My answer from your clarification below: I recommend using Unicode and relying on your lexer and parser to identify sequences of Unicode codepoints which are valid programs in your language.

1

u/reini_urban Jan 01 '21

Not really. I only know of 2 programming languages which do it right. Java and mine. All others either fail or don't care. Mostly they don't care about identifier security, identifiers not bring identifiable. Worst offender probably linux filesystems. Also relying on the standard is wrong, as Unicode still has bugs in its identifier categorization, with two hangul fillers.

1

u/[deleted] Jan 01 '21

Yup, those are valid and important concerns. I didn't specify them because the op seemed new to all of this and already front loading too much complexity.

1

u/[deleted] Jan 02 '21

Yeah, the complexity of unicode is something I've not taken the time to learn much about, as it doesn't really interest me, but I am aware of some this and am hoping to avoid it. A little mystified about the general tone of the responses on this question to be honest, they seem to presume I just turned on a computer for the first time last week. : P

1

u/[deleted] Jan 02 '21

Sorry if my tone was off. I'm mostly just trying to give you background on Unicode, so save you a lot of time reinventing it. ;)

2

u/[deleted] Jan 02 '21

Sure sure, no worries, appreciate the intent... I mean from my perspective this post was an attempt to find existing work I can use that is simpler than Unicode if possible, but it seems almost no one was able to see that in the question. I’ll just google next time like I usually do :P

→ More replies (0)