Four-char code
From REALbasicWiki
| Overall article skill | ✭ |
A four-char code is a 32 bits integer which is read as a string, or the other way round.
Each byte is 8 bits, so 32 bits correspond to 4 bytes and each byte is a value between 0 and 255. Old character encodings make each character corresponds to one byte. For example, the character "A" correspond to the value 65.
[edit] Gosh, what are you talking about ?
Processors can easily compare 4 bytes values but programmers want to use meaningful values. If programmers use a four character code which is meaningful to them, such code can be easily translated to a 32 bits integer which is nice for the processor. For example, "curs" can stand for "cursor" in a developer's language but it can be efficiently transformed into a 32 bits integer for the processor.
[edit] Use of four-char codes
- On the Macintosh, four-char codes (called OSTypes), are heavily used in resource fork, Apple Events, files creator code and file type and many other parts of the system.
- In video file formats, four-char codes are usually used to to indicate the format for each stream. For example, "mp2v" stands for "MPEG-2 video" and "mp2a" for "MPEG-2 audio".
