Broken barFeminine ordinal
ASCII 166 is ¦ on Windows and ª in old DOS.
¦ (Broken Bar) is byte 166 in Windows-1252, Unicode U+00A6. It's a vertical line with a gap in the middle. Older PC keyboards printed the pipe key with that gap, and some fonts still draw | that way, so people go looking for the broken version and find this one. The two aren't interchangeable. A shell only pipes on | (0x7C), and a Markdown table only splits columns on it, so ls ¦ grep or a table built with ¦ comes out as literal text. The UK keyboard layout puts both on separate keys, which makes the mix-up easy. In UTF-8 it's C2 A6, and the HTML entity is ¦.
ª (Feminine Ordinal) is byte 166 in code page 437, the original IBM PC character set, and maps to Unicode U+00AA. Windows-1252 has the broken bar ¦ at 166, so Spanish DOS text read as Windows-1252 turns 1.ª planta into 1.¦ planta. Code page 850 kept ª at 166 too. Its masculine partner º is the next byte, 167.
#include <stdio.h>int main(void) {/* On Windows (code page 1252) byte 166 is ¦.Modern terminals expect UTF-8, so print the code point, not the byte. */printf("\u00A6\n"); /* UTF-8: C2 A6 */unsigned char b = 166; /* the raw Windows-1252 byte */printf("%d 0x%02X\n", b, b); /* 166 0xA6 */return 0;}
#include <stdio.h>int main(void) {/* Byte 166 is ª only on a console using code page 437(chcp 437 on Windows, or DOSBox). On a UTF-8 terminal thelone byte 0xA6 is invalid and prints as garbage, often �. */putchar(166);/* char is signed on x86, so a plain char holding 0xA6 is -90.Use unsigned char when you compare or index by byte value. */char c = (char)166;unsigned char u = 166;printf("\n%d %d\n", c, u); /* -90 166 *//* Portable: print the Unicode character as UTF-8 instead. */printf("\u00AA\n"); /* C2 AA */return 0;}
ª is also ASCII 170 on Windows, which has the full guide.
The browser is reading a UTF-8 page as Windows-1252, often because the charset tag comes too late to count. The spec wants `<meta charset="utf-8">` inside the first 1024 bytes, and browsers can miss it past that point, so make it the first line in the head, ahead of any inline scripts or styles.
Windows-1252 is reading bytes a DOS program wrote, and the DOS ª sits exactly where Windows keeps ¦. º breaks the same way and turns into §, so Nº comes out as N§. For a single file, reopen it in any editor that lets you choose the encoding, pick code page 850, and save it back as UTF-8.
Windows-1252 is reading bytes a DOS program wrote, and the DOS ª sits exactly where Windows keeps ¦. º breaks the same way and turns into §, so Nº comes out as N§. For a single file, reopen it in any editor that lets you choose the encoding, pick code page 850, and save it back as UTF-8.