Unicode and Beta

This may be the most niche post in the history of the internet.  Nay, since the invention of the wheel.  Make that since the invention of time.

So, CPN Tools is written in Beta.  Beta is a programming language made Ole Lehrmann Madsen, Kristen Nygaard  ((Of Simula fame.  He was also one of the inventors of object oriented programming.)), and Birger Møller-Pedersen and later maintained by Mjølner Informatics.  When I started working with Beta, some 10 years ago, it was already a dying language.

Today, I’m guessing I’m the only person coding in Beta.  This is mostly because CPN Tools comprises around 130,000 lines of Beta code and as I’m the only one maintaining it, there’s very little chance I’ll rewrite it in a modern language.

Now I need to make CPN Tools handle Unicode in some limited situations.  I am NOT happy about that, but there you go.  Beta has preliminary support for Unicode from back when Unicode characters still were 16 bits (today they’re 32 bits with the first 8 guaranteed to be zero, IIRC), and I need to represent it is UTF8, which is not supported by Beta.

This calls for bit-level operations, which were never fully integrated in Beta.  Really, look at this old manual for the low-level operations.  Not that it is much better than the regular syntax for Beta, which looks like some teenager puked out a week’s supply of smilies.  Ole once told the story about how the syntax for Beta was conceived, and it did involve generous amounts of whisky and red wine.

Anyway, I have written some code which may or may not convert to a string to UTF8.  I decided to post the above instead of testing it, so here goes:

I have a feeling this is the largest chunk of new Beta code written in at least 5 years (not counting GBeta, which is a modernized version with a C-like syntax).

Edit: I suck at translating binary to hex in my head, so the 0xa0 should be 0xc0 and 0xb0 0xd0, but that is hardly Beta’s fault.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.