#! /usr/bin/python3
#-*- coding: utf-8 -*-
"""
Převod kodování bratrů Kamenických do UTF8
------------------------------------------
PhDr. Mgr. Jeroným Klimeš, Ph.D. 2023-08-27
Přehrabával jsem se starými soubory z T602. Dají se natáhnout do Libreoffice,
ale stejně jsem zjistil, že neexistuje jednoduchý převodník z kodování bratrů
Kamenických čili CP895 alias KEYBCS2 do kódování UTF-8, co se dnes obecně
používá v Linuxu.
Někde na Internetu jsem našel převodní tabulku, co je na konci souboru, a podle
ní jsem napsal jednoduchý převodník, který pipuje z kameníků do utf.
Použití je prosté:
Celý tento soubor uložte do souboru s názvem: kamenicti_utf8_pipe.py
Nezapomeňte, že tento skript musí být spustitelný.
chmod +x ./kamenicti_utf8_pipe.py
cat VSTUP.602 | ./kamenicti_utf8_pipe.py > vystup_602.txt
"./" na začátku tam dejte, když se snažíte spustit program, který není tzv. v cestě.
Pak to můžete rovnou editovat v jakémkoli programu. Třeba v kwrite, který rád používám. Například i tento výstup byl vyroben pomocí jeho.
sudo apt install kwrite
"""
import sys
import unicodedata
znakyU=("\u0000", "\u0001", "\u0002", "\u0003", "\u0004", "\u0005", "\u0006", "\u0007", "\u0008", "\u0009", "\u000a", "\u000b", "\u000c", "\u000d", "\u000e", "\u000f", "\u0010", "\u0011", "\u0012", "\u0013", "\u0014", "\u0015", "\u0016", "\u0017", "\u0018", "\u0019", "\u001a", "\u001b", "\u001c", "\u001d", "\u001e", "\u001f", "\u0020", "\u0021", "\u0022", "\u0023", "\u0024", "\u0025", "\u0026", "\u0027", "\u0028", "\u0029", "\u002a", "\u002b", "\u002c", "\u002d", "\u002e", "\u002f", "\u0030", "\u0031", "\u0032", "\u0033", "\u0034", "\u0035", "\u0036", "\u0037", "\u0038", "\u0039", "\u003a", "\u003b", "\u003c", "\u003d", "\u003e", "\u003f", "\u0040", "\u0041", "\u0042", "\u0043", "\u0044", "\u0045", "\u0046", "\u0047", "\u0048", "\u0049", "\u004a", "\u004b", "\u004c", "\u004d", "\u004e", "\u004f", "\u0050", "\u0051", "\u0052", "\u0053", "\u0054", "\u0055", "\u0056", "\u0057", "\u0058", "\u0059", "\u005a", "\u005b", "\u005c", "\u005d", "\u005e", "\u005f", "\u0060", "\u0061", "\u0062", "\u0063", "\u0064", "\u0065", "\u0066", "\u0067", "\u0068", "\u0069", "\u006a", "\u006b", "\u006c", "\u006d", "\u006e", "\u006f", "\u0070", "\u0071", "\u0072", "\u0073", "\u0074", "\u0075", "\u0076", "\u0077", "\u0078", "\u0079", "\u007a", "\u007b", "\u007c", "\u007d", "\u007e", "\u007f", "\u010C", "\u00FC", "\u00E9", "\u010F", "\u00e4", "\u010E", "\u0164", "\u010D", "\u011B", "\u011a", "\u0139", "\u00CD", "\u013E", "\u013A", "\u00C4", "\u00C1", "\u00C9", "\u017E", "\u017D", "\u00F4", "\u00F6", "\u00D3", "\u016F", "\u00DA", "\u00FD", "\u00d6", "\u00dc", "\u0160", "\u013D", "\u00DD", "\u0158", "\u0165", "\u00e1", "\u00ed", "\u00f3", "\u00fa", "\u0148", "\u0147", "\u016E", "\u00D4", "\u0161", "\u0159", "\u0155", "\u0154", "\u00bc", "\u00a7", "\u00ab", "\u00bb", "\u2591", "\u2592", "\u2593", "\u2502", "\u2524", "\u2561", "\u2562", "\u2556", "\u2555", "\u2563", "\u2551", "\u2557", "\u255d", "\u255c", "\u255b", "\u2510", "\u2514", "\u2534", "\u252c", "\u251c", "\u2500", "\u253c", "\u255e", "\u255f", "\u255a", "\u2554", "\u2569", "\u2566", "\u2560", "\u2550", "\u256c", "\u2567", "\u2568", "\u2564", "\u2565", "\u2559", "\u2558", "\u2552", "\u2553", "\u256b", "\u256a", "\u2518", "\u250c", "\u2588", "\u2584", "\u258c", "\u2590", "\u2580", "\u03b1", "\u00df", "\u0393", "\u03c0", "\u03a3", "\u03c3", "\u00b5", "\u03c4", "\u03a6", "\u0398", "\u03a9", "\u03b4", "\u221e", "\u03c6", "\u03b5", "\u2229", "\u2261", "\u00b1", "\u2265", "\u2264", "\u2320", "\u2321", "\u00f7", "\u2248", "\u00b0", "\u2219", "\u00b7", "\u221a", "\u207f", "\u00b2", "\u25a0", "\u00a0")
byte = sys.stdin.buffer.read(1)
while byte != b'':
ord_byte=ord(byte)
sys.stdout.write(znakyU[ord(byte)])
byte = sys.stdin.buffer.read(1)
quit()
"""
#
# CP895 alias KEYBCS2, Kamenicti to Unicode
#
0x00 U+0000 # NULL
0x01 U+0001 # START OF HEADING
0x02 U+0002 # START OF TEXT
0x03 U+0003 # END OF TEXT
0x04 U+0004 # END OF TRANSMISSION
0x05 U+0005 # ENQUIRY
0x06 U+0006 # ACKNOWLEDGE
0x07 U+0007 # BELL
0x08 U+0008 # BACKSPACE
0x09 U+0009 # HORIZONTAL TABULATION
0x0a U+000a # LINE FEED
0x0b U+000b # VERTICAL TABULATION
0x0c U+000c # FORM FEED
0x0d U+000d # CARRIAGE RETURN
0x0e U+000e # SHIFT OUT
0x0f U+000f # SHIFT IN
0x10 U+0010 # DATA LINK ESCAPE
0x11 U+0011 # DEVICE CONTROL ONE
0x12 U+0012 # DEVICE CONTROL TWO
0x13 U+0013 # DEVICE CONTROL THREE
0x14 U+0014 # DEVICE CONTROL FOUR
0x15 U+0015 # NEGATIVE ACKNOWLEDGE
0x16 U+0016 # SYNCHRONOUS IDLE
0x17 U+0017 # END OF TRANSMISSION BLOCK
0x18 U+0018 # CANCEL
0x19 U+0019 # END OF MEDIUM
0x1a U+001a # SUBSTITUTE
0x1b U+001b # ESCAPE
0x1c U+001c # FILE SEPARATOR
0x1d U+001d # GROUP SEPARATOR
0x1e U+001e # RECORD SEPARATOR
0x1f U+001f # UNIT SEPARATOR
0x20 U+0020 # SPACE
0x21 U+0021 # EXCLAMATION MARK
0x22 U+0022 # QUOTATION MARK
0x23 U+0023 # NUMBER SIGN
0x24 U+0024 # DOLLAR SIGN
0x25 U+0025 # PERCENT SIGN
0x26 U+0026 # AMPERSAND
0x27 U+0027 # APOSTROPHE
0x28 U+0028 # LEFT PARENTHESIS
0x29 U+0029 # RIGHT PARENTHESIS
0x2a U+002a # ASTERISK
0x2b U+002b # PLUS SIGN
0x2c U+002c # COMMA
0x2d U+002d # HYPHEN-MINUS
0x2e U+002e # FULL STOP
0x2f U+002f # SOLIDUS
0x30 U+0030 # DIGIT ZERO
0x31 U+0031 # DIGIT ONE
0x32 U+0032 # DIGIT TWO
0x33 U+0033 # DIGIT THREE
0x34 U+0034 # DIGIT FOUR
0x35 U+0035 # DIGIT FIVE
0x36 U+0036 # DIGIT SIX
0x37 U+0037 # DIGIT SEVEN
0x38 U+0038 # DIGIT EIGHT
0x39 U+0039 # DIGIT NINE
0x3a U+003a # COLON
0x3b U+003b # SEMICOLON
0x3c U+003c # LESS-THAN SIGN
0x3d U+003d # EQUALS SIGN
0x3e U+003e # GREATER-THAN SIGN
0x3f U+003f # QUESTION MARK
0x40 U+0040 # COMMERCIAL AT
0x41 U+0041 # LATIN CAPITAL LETTER A
0x42 U+0042 # LATIN CAPITAL LETTER B
0x43 U+0043 # LATIN CAPITAL LETTER C
0x44 U+0044 # LATIN CAPITAL LETTER D
0x45 U+0045 # LATIN CAPITAL LETTER E
0x46 U+0046 # LATIN CAPITAL LETTER F
0x47 U+0047 # LATIN CAPITAL LETTER G
0x48 U+0048 # LATIN CAPITAL LETTER H
0x49 U+0049 # LATIN CAPITAL LETTER I
0x4a U+004a # LATIN CAPITAL LETTER J
0x4b U+004b # LATIN CAPITAL LETTER K
0x4c U+004c # LATIN CAPITAL LETTER L
0x4d U+004d # LATIN CAPITAL LETTER M
0x4e U+004e # LATIN CAPITAL LETTER N
0x4f U+004f # LATIN CAPITAL LETTER O
0x50 U+0050 # LATIN CAPITAL LETTER P
0x51 U+0051 # LATIN CAPITAL LETTER Q
0x52 U+0052 # LATIN CAPITAL LETTER R
0x53 U+0053 # LATIN CAPITAL LETTER S
0x54 U+0054 # LATIN CAPITAL LETTER T
0x55 U+0055 # LATIN CAPITAL LETTER U
0x56 U+0056 # LATIN CAPITAL LETTER V
0x57 U+0057 # LATIN CAPITAL LETTER W
0x58 U+0058 # LATIN CAPITAL LETTER X
0x59 U+0059 # LATIN CAPITAL LETTER Y
0x5a U+005a # LATIN CAPITAL LETTER Z
0x5b U+005b # LEFT SQUARE BRACKET
0x5c U+005c # REVERSE SOLIDUS
0x5d U+005d # RIGHT SQUARE BRACKET
0x5e U+005e # CIRCUMFLEX ACCENT
0x5f U+005f # LOW LINE
0x60 U+0060 # GRAVE ACCENT
0x61 U+0061 # LATIN SMALL LETTER A
0x62 U+0062 # LATIN SMALL LETTER B
0x63 U+0063 # LATIN SMALL LETTER C
0x64 U+0064 # LATIN SMALL LETTER D
0x65 U+0065 # LATIN SMALL LETTER E
0x66 U+0066 # LATIN SMALL LETTER F
0x67 U+0067 # LATIN SMALL LETTER G
0x68 U+0068 # LATIN SMALL LETTER H
0x69 U+0069 # LATIN SMALL LETTER I
0x6a U+006a # LATIN SMALL LETTER J
0x6b U+006b # LATIN SMALL LETTER K
0x6c U+006c # LATIN SMALL LETTER L
0x6d U+006d # LATIN SMALL LETTER M
0x6e U+006e # LATIN SMALL LETTER N
0x6f U+006f # LATIN SMALL LETTER O
0x70 U+0070 # LATIN SMALL LETTER P
0x71 U+0071 # LATIN SMALL LETTER Q
0x72 U+0072 # LATIN SMALL LETTER R
0x73 U+0073 # LATIN SMALL LETTER S
0x74 U+0074 # LATIN SMALL LETTER T
0x75 U+0075 # LATIN SMALL LETTER U
0x76 U+0076 # LATIN SMALL LETTER V
0x77 U+0077 # LATIN SMALL LETTER W
0x78 U+0078 # LATIN SMALL LETTER X
0x79 U+0079 # LATIN SMALL LETTER Y
0x7a U+007a # LATIN SMALL LETTER Z
0x7b U+007b # LEFT CURLY BRACKET
0x7c U+007c # VERTICAL LINE
0x7d U+007d # RIGHT CURLY BRACKET
0x7e U+007e # TILDE
0x7f U+007f # DELETE
##
0x80 U+010C # LATIN CAPITAL LETTER C WITH CARON
0x81 U+00FC # LATIN SMALL LETTER U WITH DIAERESIS
0x82 U+00E9 # LATIN SMALL LETTER E WITH ACUTE
0x83 U+010F # LATIN SMALL LETTER D WITH CARON
0x84 U+00e4 # LATIN SMALL LETTER A WITH DIAERESIS
0x85 U+010E # LATIN CAPITAL LETTER D WITH CARON
0x86 U+0164 # LATIN CAPITAL LETTER T WITH CARON
0x87 U+010D # LATIN SMALL LETTER C WITH CARON
0x88 U+011B # LATIN SMALL LETTER E WITH CARON
0x89 U+011a # LATIN CAPITAL LETTER E WITH CARON
0x8A U+0139 # LATIN CAPITAL LETTER L WITH ACUTE
0x8B U+00CD # LATIN CAPITAL LETTER I WITH ACUTE
0x8C U+013E # LATIN SMALL LETTER L WITH CARON
0x8D U+013A # LATIN SMALL LETTER L WITH ACUTE
0x8E U+00C4 # LATIN CAPITAL LETTER A WITH DIAERESIS
0x8F U+00C1 # LATIN CAPITAL LETTER A WITH ACUTE
0x90 U+00C9 # LATIN CAPITAL LETTER E WITH ACUTE
0x91 U+017E # LATIN SMALL LETTER Z WITH CARON
0x92 U+017D # LATIN CAPITAL LETTER Z WITH CARON
0x93 U+00F4 # LATIN SMALL LETTER O WITH CIRCUMFLEX
0x94 U+00F6 # LATIN SMALL LETTER O WITH DIAERESIS
0x95 U+00D3 # LATIN CAPITAL LETTER O WITH ACUTE
0x96 U+016F # LATIN SMALL LETTER U WITH RING ABOVE
0x97 U+00DA # LATIN CAPITAL LETTER U WITH ACUTE
0x98 U+00FD # LATIN SMALL LETTER Y WITH ACUTE
0x99 U+00d6 # LATIN CAPITAL LETTER O WITH DIAERESIS
0x9a U+00dc # LATIN CAPITAL LETTER U WITH DIAERESIS
0x9b U+0160 # LATIN CAPITAL LETTER S WITH CARON
0x9c U+013D # LATIN CAPITAL LETTER L WITH CARON
0x9d U+00DD # LATIN CAPITAL LETTER Y WITH ACUTE
0x9e U+0158 # LATIN CAPITAL LETTER R WITH CARON
0x9f U+0165 # LATIN SMALL LETTER T WITH CARON
0xa0 U+00e1 # LATIN SMALL LETTER A WITH ACUTE
0xa1 U+00ed # LATIN SMALL LETTER I WITH ACUTE
0xa2 U+00f3 # LATIN SMALL LETTER O WITH ACUTE
0xa3 U+00fa # LATIN SMALL LETTER U WITH ACUTE
0xa4 U+0148 # LATIN SMALL LETTER N WITH CARON
0xa5 U+0147 # LATIN CAPITAL LETTER N WITH CARON
0xa6 U+016E # LATIN CAPITAL LETTER U WITH RING ABOVE
0xa7 U+00D4 # LATIN CAPITAL LETTER O WITH CIRCUMFLEX
0xa8 U+0161 # LATIN SMALL LETTER S WITH CARON
0xa9 U+0159 # LATIN SMALL LETTER R WITH CARON
0xaa U+0155 # LATIN SMALL LETTER R WITH ACUTE
0xab U+0154 # LATIN CAPITAL LETTER R WITH ACUTE
0xac U+00bc # VULGAR FRACTION ONE QUARTER
0xad U+00a7 # SECTION SIGN
0xae U+00ab # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0xaf U+00bb # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0xb0 U+2591 # LIGHT SHADE
0xb1 U+2592 # MEDIUM SHADE
0xb2 U+2593 # DARK SHADE
0xb3 U+2502 # BOX DRAWINGS LIGHT VERTICAL
0xb4 U+2524 # BOX DRAWINGS LIGHT VERTICAL AND LEFT
0xb5 U+2561 # BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
0xb6 U+2562 # BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
0xb7 U+2556 # BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
0xb8 U+2555 # BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
0xb9 U+2563 # BOX DRAWINGS DOUBLE VERTICAL AND LEFT
0xba U+2551 # BOX DRAWINGS DOUBLE VERTICAL
0xbb U+2557 # BOX DRAWINGS DOUBLE DOWN AND LEFT
0xbc U+255d # BOX DRAWINGS DOUBLE UP AND LEFT
0xbd U+255c # BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
0xbe U+255b # BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
0xbf U+2510 # BOX DRAWINGS LIGHT DOWN AND LEFT
0xc0 U+2514 # BOX DRAWINGS LIGHT UP AND RIGHT
0xc1 U+2534 # BOX DRAWINGS LIGHT UP AND HORIZONTAL
0xc2 U+252c # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
0xc3 U+251c # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
0xc4 U+2500 # BOX DRAWINGS LIGHT HORIZONTAL
0xc5 U+253c # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
0xc6 U+255e # BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
0xc7 U+255f # BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
0xc8 U+255a # BOX DRAWINGS DOUBLE UP AND RIGHT
0xc9 U+2554 # BOX DRAWINGS DOUBLE DOWN AND RIGHT
0xca U+2569 # BOX DRAWINGS DOUBLE UP AND HORIZONTAL
0xcb U+2566 # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
0xcc U+2560 # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
0xcd U+2550 # BOX DRAWINGS DOUBLE HORIZONTAL
0xce U+256c # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
0xcf U+2567 # BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
0xd0 U+2568 # BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
0xd1 U+2564 # BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
0xd2 U+2565 # BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
0xd3 U+2559 # BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
0xd4 U+2558 # BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
0xd5 U+2552 # BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
0xd6 U+2553 # BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
0xd7 U+256b # BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
0xd8 U+256a # BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
0xd9 U+2518 # BOX DRAWINGS LIGHT UP AND LEFT
0xda U+250c # BOX DRAWINGS LIGHT DOWN AND RIGHT
0xdb U+2588 # FULL BLOCK
0xdc U+2584 # LOWER HALF BLOCK
0xdd U+258c # LEFT HALF BLOCK
0xde U+2590 # RIGHT HALF BLOCK
0xdf U+2580 # UPPER HALF BLOCK
0xe0 U+03b1 # GREEK SMALL LETTER ALPHA
0xe1 U+00df # LATIN SMALL LETTER SHARP S
0xe2 U+0393 # GREEK CAPITAL LETTER GAMMA
0xe3 U+03c0 # GREEK SMALL LETTER PI
0xe4 U+03a3 # GREEK CAPITAL LETTER SIGMA
0xe5 U+03c3 # GREEK SMALL LETTER SIGMA
0xe6 U+00b5 # MICRO SIGN
0xe7 U+03c4 # GREEK SMALL LETTER TAU
0xe8 U+03a6 # GREEK CAPITAL LETTER PHI
0xe9 U+0398 # GREEK CAPITAL LETTER THETA
0xea U+03a9 # GREEK CAPITAL LETTER OMEGA
0xeb U+03b4 # GREEK SMALL LETTER DELTA
0xec U+221e # INFINITY
0xed U+03c6 # GREEK SMALL LETTER PHI
0xee U+03b5 # GREEK SMALL LETTER EPSILON
0xef U+2229 # INTERSECTION
0xf0 U+2261 # IDENTICAL TO
0xf1 U+00b1 # PLUS-MINUS SIGN
0xf2 U+2265 # GREATER-THAN OR EQUAL TO
0xf3 U+2264 # LESS-THAN OR EQUAL TO
0xf4 U+2320 # TOP HALF INTEGRAL
0xf5 U+2321 # BOTTOM HALF INTEGRAL
0xf6 U+00f7 # DIVISION SIGN
0xf7 U+2248 # ALMOST EQUAL TO
0xf8 U+00b0 # DEGREE SIGN
0xf9 U+2219 # BULLET OPERATOR
0xfa U+00b7 # MIDDLE DOT
0xfb U+221a # SQUARE ROOT
0xfc U+207f # SUPERSCRIPT LATIN SMALL LETTER N
0xfd U+00b2 # SUPERSCRIPT TWO
0xfe U+25a0 # BLACK SQUARE
0xff U+00a0 # NO-BREAK SPACE
"""