Category Archives: software & technology - Page 3

Definitions in character terminology

I would like to sum up the terminology (as far as I understand it):

Mojibake
Character in encoding X was decoded using encoding Y
glyph
A character / symbol identified by its shape
character
A digital representation of a glyph as code point
code point
An integer (mostly listed as hex code) representing / referring to a character
charset (abbr. character set)
A set of associations between code points and characters
encoding
A set of conventions to transform a code point to a byte string (always in respect of a charset)
character string
A string with 1 glyph / character as a unit
byte string
Character string encoded (in a specific encoding)

For example, the glyph A consists of three lines and is the first letter in the latin alphabet (which defines a set of characters). If you put two dots at its top (Ä) and decode its UTF-8 representation as latin1, you will get a mojibake Ü. The A’s code point in ASCII-compliant encodings such as Unicode is 65 (0×41). The charset UTF-8 defines the association between 65 and A and for charset UTF-8, the encoding is Unicode. Only 1 byte is required to store 0×41 in the memory (in UTF-8 charset) which is binary 101010. So the bytestring of A looks like this in binary: (01000001, ).

On the issue of float, double and long

#include <stdio.h>
// Test environment:
//    Thinkpad Lenovo x201 -- 64bit, gcc 4.5.1, Linux Fedora

int main()
{
  // [0] error: both ‘long’ and ‘float’ in declaration specifiers
  // [1] error: both ‘long long’ and ‘double’ in declaration specifiers

  int a = 1;
  long int b = 1;
  int long c = 1;
  long long int d = 1;
  int long long e = 1;

  float f = 1.0;
  //float long g = 1.0; // [0]
  //long float h = 1.0; // [0]
  //float long long i = 1.0; // [0] [0]
  //long long float j = 1.0; // [0]

  double o = 1.0;
  long double p = 1.0;
  double long q = 1.0;
  //long long double r = 1.0; // [1]
  //double long long s = 1.0; // [1]

  printf("%zun", sizeof(a)); // 4
  printf("%zun", sizeof(b)); // 8
  printf("%zun", sizeof(c)); // 8
  printf("%zun", sizeof(d)); // 8
  printf("%zun", sizeof(e)); // 8
  printf("%zun", sizeof(f)); // 4
  printf("%zun", sizeof(o)); // 8
  printf("%zun", sizeof(p)); // 16
  printf("%zun", sizeof(q)); // 16
  printf("%lfn", o); // 1.000000
  return 0;
}
  1. Why is “double” not “long float”? Replace “double” with “float long” in the example above and you will recognize some consistency.
  2. See the line before “return 0″. Double is semantically a “long float” for printf.
  3. Why is the error of “float long long” printed twice?
  4. As everybody should know, datatypes of C are not bound to any length of size. [wiki]
  5. According to GCC, “float” is defined as “float” < “double” < “double long” with a radix of 2
  6. I don’t like C :-(

Probably, maybe, …

The canPlayType() function doesn’t return true or false. In recognition of how complex video formats are, the function returns a string:

  • "probably" if the browser is fairly confident it can play this format
  • "maybe" if the browser thinks it might be able to play this format
  • "" (an empty string) if the browser is certain it can’t play this format

:-D Sounds like an easteregg, but isn’t…

via Dive into HTML5: Video formats

What C needs…

  • no undefined behaviour (prefer Compile Errors over strange behaviour)
  • Garbage Collector (reference counter)
  • Polymorphism / Multimethods (function identifier by signature / API)
  • no NULL terminated strings
  • Namespaces

thanks for the discussion, name

C and printf

#include <stdio.h>

int main()
{
  unsigned int x = 0;
  unsigned int y = x - 1;
  printf("%d n", y);
  printf("%d n", y < 0);
  return 0;
}

Ausgabe?

-1
0

C is evil :-(

The Right Tool: Python vs. PHP

This article is one year old. Accidently I did not post it in the past. So here we go with an updated version.

The Right Tool offers a nice survey, asking to rank the programming languages you select, in a suitable order related to a statement (2705 9383 programmers did it yet). Even though, I think I have experience with several languages, I was interested in comparing my “two Big Ones” (PHP and Python). And these are the results of the survey:

PHP vs Python - Programming Languages

PHP vs. Python [outdated]

Note: For PHP “ranked highly” number 3 stands for “The thought that I may still be using this language in twenty years time fills me with dread” and “ranked low” number 3 voted to number 1. For Python “ranked highly” number 2 states “This language would be good for teaching children to write software” and “ranked low” number 3 says “This language has an annoying syntax” today… oder checkout PHP and python

The PHP community is not that self esteemed like the Python community. Even though many programmers rank Python as an “unusual bad language for beginners” language, Python is listed as one of the “best languages for beginners”. On the other hand, we have what I love about python and is listed as number 1 number 5 in comparison to other languages:

This programming language has an annoying syntax
Note: Cobol is to the left and Scheme to the right today.

Windows + UUI = ubuntu

How sad. I had to use Windows and Universal USB Installer to get ubuntu up and running :-(

  • “Startup Disk Creator” threw an error when trying to boot. “Wrong password in configuration file”
  • dd-created USB sticks were simply ignored. Even though non-bootable FAT32-USB-Sticks were detected as “non-bootable device”
  • UNetbootIn same issue like Startup Disk Creator

Disclaimer: BIOS settings were adjusted and I put ubuntu at the whole USB device

LaTeX listings – hide comments

The listings package documentation was not useful for me.

lstset{commentstyle={color{white}}}

… is a possibility, but not a beautiful one (eg. marking text will show the text). Jo has found the command I couldn’t get from the documentation.

lstset{morecomment=[is]{//}{.}}

Tags: LaTeX, listings, lstset, source code, comment, hide, invisible, remove

Thanks to Jo

Dandling Else

Hübsches Dandling Else in der Software zur Erstellung unserer Hausübung :-)

    if($number==0)
	    echo "Keine Benutzer eingetragen!";
    else
		echo $number." Benutzer eingetragen        n";
		echo "      wähle Benutzername: ";

LaTeX Paket für deutsches Abkürzungsverzeichnis

Wenn jemand ein Abkürzungsverzeichnis für LaTeX sucht, stößt er unweigerlich auf das Paket acronym. Allerdings kann acronym per default nicht mit Umlauten umgehen. Diese werde kryptisch dargestellt und der Kompiler wirft zahlreiche Fehler. Die folgenden Anweisungen unterstützen den Umgang mit deutschen Zeichen (bitte verwendet UTF-8! – usepackage[utf8]{inputenc}).

usepackage[T1]{fontenc}
usepackage{lmodern}

English Version:
If you are searching for an LaTeX package handling acronyms, the acronym package will do the job for you. But only as long as you don’t use german umlauts. They will be displayed as cryptic characters and will throw several errors. The commands above will help you with this. Please prefer to use UTF-8 as inputencoding to avoid any conflicts (usepackage[utf8]{inputenc}).