Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Showing posts sorted by relevance for query unicode. Sort by date Show all posts
Showing posts sorted by relevance for query unicode. Sort by date Show all posts

Thursday, May 5, 2016

Characters

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky

Nokia - Bell Labs
Nokia - Bell Labs, The C Programming Langugage, AKA K & R, but nothing here
UTF-8 - Wikipedia
Strings, bytes, runes and characters in Go
The Unicode Consortium - OMG, they're talking about Emoji!
So the people were forced to come up with the bizarre convention of storing a FE FF at the beginning of every Unicode string; this is called a Unicode Byte Order Mark and if you are swapping your high and low bytes it will look like a FF FE and the person reading your string will know that they have to swap every other byte. Phew. Not every Unicode string in the wild has a byte order mark at the beginning.
Bits of
code point
First
code point
Last
code point
Bytes in
sequence
Byte 1Byte 2Byte 3Byte 4Byte 5Byte 6
  7U+0000U+007F10xxxxxxx
11U+0080U+07FF2110xxxxx10xxxxxx
16U+0800U+FFFF31110xxxx10xxxxxx10xxxxxx
21U+10000U+1FFFFF411110xxx10xxxxxx10xxxxxx10xxxxxx
The following sequences are not part of the UTF-8 standard, only part of the original proposal
26U+200000U+3FFFFFF5111110xx10xxxxxx10xxxxxx10xxxxxx10xxxxxx
31U+4000000U+7FFFFFFF61111110x10xxxxxx10xxxxxx10xxxxxx10xxxxxx10xxxxxx

Here's a 'C' procedure from magaiti that will tell you how many bytes the next character occupies:
int get_mbchar_length(char lb) {
    if (( lb & 0xE0 ) == 0xC0 ) return 2;
    if (( lb & 0xF0 ) == 0xE0 ) return 3;
    if (( lb & 0xF8 ) == 0xF0 ) return 4;
    return 1;
}

For the Snake Encoding problem on Codingame dot com, I used unicode/utf8 as suggested by Rob Pike.

Tuesday, February 11, 2020

Curses

Unicode Logo
I have been working a little program to solve the domino puzzle Stu posted last week. Why push dominos around for minutes when I can spend hours writing a program to solve it in milliseconds? Yeah, well, we all have our faults.

So I've got the program pretty much working, but I thought it might be nice to display the results graphically. Yes, html is glorious, put I don't want to open that can of worms. If I could just find the codes for the old IBM PC box drawing characters, I could cobble something together that would be adequate.

So I went rooting around on the net, and because I am using Linux, whenever I asked for box drawing characters and Linux, I got ncurses, which stands for new curses, which is some kind or proto-windowing system for terminals. I go round and round with this for a while, but never get anywhere because none of the sample programs will compile because I don't have some unspecified library installed. I eventually realized that the C programming language, my text editor and Linux in general all work perfectly well with unicode characters and I don't have any need for ncurses at all.

I've probably been down this road before, but I'll be durned if I can remember where. In any case, I wrote a little program to turn unicode values into unicode character strings and uploaded it to github.

Stackexchange is useless. It is occupied by gnome-like creatures who know everything there is to know, but are incapable of answering a simple question.

Thursday, November 4, 2021

Is it cosmic?

 I read a post the other day about Bi Directional printing. The post was on Schneier on Security and is about how malicious code can be inserted into source code. It does this by looking innocent. However when the compiler reads the file, it gets parts of it in different order than what you see on the screen. I think we can presume the compiler gets the raw file and what we see on the screen has been rearranged according to the constraints of the window and the formatting control characters embedded in the file.


Golden Earring - Twilight Zone (Extended Long Version)
Opening Salvo

There was an example posted so I thought I would try it out. The sample, however, did not have the control codes embedded in it, all it gave you were the two examples, one with control codes active and one without. So I thought I would give it a try, I mean it shouldn't be two hard to open up some kind of text editor and insert a couple of control codes, should it? Well, for some reason, man, the find function on my text editor has flat quit working. Do-do-Do-do - are we in the Twilight Zone?

I've been threatening to replace my Linux box with a Chromebox. You can buy them now. A few years ago you couldn't, you had to roll your own, and that was too much trouble. I'd gone through that in setting up my Linux box, but after having been using it for years without having to get back under the hood* I'm not keen to do so now.

I've been threatening to replace my Linux box with a Chromebox. You don't suppose the Linux box was listening in, do you? I mean it's what I use for all my web surfing, surfing for a new Chromebook (drool). Do I get a high power one or do I get a one with a Celeron processor? I think the high power ones also use an Intel processor with some kind of alpha-numeric name. And then there's the question of memory. I think I have a choice of 4, 8 or 16 gigabytes. I think this box, the one I'm using, has 4, but I can't be bothered to check. I guess I'm a little irritated, all that time I spent screwing around, waiting for computers to boot up. Maybe that's why I did it, I was a glutton for punishment, people looked at the job in passing and just passed on by. A smarter me might have done that, but I guess that's just who I am. There is a certain satisfaction in successfully jumping through all the hoops and finally getting the machine to behave. 

A couple of weeks ago, four of us spent the afternoon moving a big piece of cast iron a couple of miles across the west side. Any complaints? No, just a chorus of 'that was fun, we should do it again some time'. Probably deprived some honest hardworking men a day's wages, but not everyone has an unlimited budget for hobbies.

Oh yeah, the control codes, from Google search:

Overriding BiDi using Unicode control characters
CharacterCode pointMarkup equivalent
Left-to-Right Isolate (LRI)U+2066dir="ltr"
Right-to-Left Isolate (LRI)U+2067dir="rtl"
First Strong Isolate (FSI)U+2068dir="auto"
Left-to-Right Embedding (LRE)U+202Adir="ltr"

I'm not quite sure just how or what to actually insert in a file, but I'm sure I'll figure it out.

*Capiche 'under the hood'? To work on an automobile engine, which used to be a very common activity but hardly ever happens any more, you had to open the hood, so all the time you were working on the engine, you were 'under the hood'. For some reason, most people, maybe 95 percent, won't ever engage in it. It might be lack of aptitude, or just simple disinclination, or possibly even a gut level revulsion. I don't know, people are weird. Anyway, 'under the hood' means getting down into the inner workings of of whatever mechanism, virtual or mechanical, is under discussion. That's a weird way to put it, 'under discussion'. The thing is broken and it needs to be fixed, there doesn't need to be any discussion. Aha! But anything worth repairing that breaks down is going to cause a discussion. Is it worth fixing? Can it be fixed? Who can do it? Should we just buy another one, it'd be quicker, etc., etc., etc.

Update April 2022 replaced missing video.



Monday, July 17, 2017

Camera Obscura

Camera Obscura at Cliff House in San Francisco
Camera Obscura is Latin for 'dark room'. Let light from a pinhole or a lens into a dark room and it will project an image of the outside world on the opposite wall, so Camera Obscura is simply a fancy name for a very simple device. They have been around for millennia, Aristotle was familiar with the principle. Uniberp pointed out this one at Cliff House. Cliff House is a famous landmark in San Francisco. Those parking spaces out front are free, but there are only a few dozen, and being as this place is famous the odds of finding an open one there when you drive up are astronomical. Are you feeling lucky, punk?

Caption from image: The Camera Obscura, which is seen at many seaside places, is a striking example of how rays of light can be reflected in a different direction by a mirror placed at a slant. In the roof is a mirror at an angle of 45°, and this catches a reflection of the scene outside. The rays are directed upon a magnifying lens, placed in the right position to focus them, and the magnified view is cast upon a white table below. The top containing the mirror can be rotated by means of a handle turning a series of gear wheels, so that an image of the view all round can be reflected upon the table. The Camera Obscura was invented by a Neapolitan physician named Porta who found that by passing light through a double-convex lens he obtained a brighter image


ADDICTED TO LOVE (1997) - Official Movie Trailer

This reminded me of this movie (Addicted to Love) where Sam the jilted uses a Camera Obscura to spy on his ex-girlfriend. The images from the device make a few brief appearances in the trailer starting at the one minute mark. The movie is absurd. It was, however, entertaining. Comedy and stupidity are blood-brothers.

P.S. How to type a degree symbol on Linux: Ctrl + Shift + u (this will show an underlined u) and then the unicode value (in this case B0 ) and follow it by Enter.

Friday, November 14, 2014

Tron Light Cycles


Tron (1982) - "Light Cycle Battle" HD
Inspiration for a entire generation of video games
 
I like programming. When I am feeling sharp I like nothing better than horribly complex problems. When I am feeling dull, like I have been for the last couple of weeks, I want simple minded problems. Coding Game has lots of problems. They all start out easy enough but some of them quickly become nasty difficult. Looking for something easy to work on I thought I would try Tron Battle, one of their older multi-player puzzles. I might run out of steam before I master it, but the preliminaries will keep me amused for a couple of hours.
    Imagine my surprise when my quick and dirty solution became a contender. It's not in the top rank but it's not down at the bottom with the dross either. Watching it run a few times against other players I thought of a couple of simple modifications. One required a modification to an existing procedure. The other required simple commenting out (removing) one line. Guess which one gave me a bigger improvement?

Update: I just looked at the result and 'export' scrambled the code, so never mind the rest of this post.
    I just noticed that Blogger has a new feature: Pages, so I've put a copy of my program over there, in case anyone is interested. The program doesn't do any fancy graphics, it's all logic, and simple minded logic at that. It simple heads in the direction with the largest open space.

P.S. Notepad++ used to have an export function that produced html with color coding. Well, the export function only works with the ANSI version and I somehow had ended up with the Unicode version, so I did a reinstall and now export works, but it doesn't do the colors anymore. Bah. Cut and paste might work just as well. And Blogger's 'Pages' are kind of narrow for code.

Update July 2025 replaced missing video with HD version.