Last active
September 14, 2021 19:41
-
-
Save ChrisHinde/8b926b75b51049e03bab9fe48126185a to your computer and use it in GitHub Desktop.
Converts a list of strings/descriptions to numeric "descriptor" for (some) Sam4s cash registers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
# Author: Christopher Hindefjord - chris.hindefjord.se | |
# September 2021 | |
# License: CC-0 (Public domain) | |
# =========================== | |
# Converts a list of strings/descriptions to numeric "descriptor" for (some) Sam4s cash registers. | |
# The character codes are taken from the "Operator's and Programming manual" for Sam4s ER-5200M/5240M! | |
# Refer to the manual of your unit, to see if it uses the same codes. | |
# | |
# USAGE: Change the values of the first array bellow [strings] to the text that you want to convert | |
# You can also change the how the resulting codes are separated (by default just a space) | |
# | |
# REQUIRES Python3+ | |
# | |
# NOTE: | |
# For character codes with one (or two) leading zeros (0) you do need to enter (on the PoS unit) | |
# the zeros for every character (except the first one), | |
# so the text ABC (A: 065, B: 066, C: 067) would need to be entered as | |
# 65066067 | |
# | |
# - - - - | |
# | |
# DISCLAIMER: | |
# No quarantees given that the output of this script produces the correct codes! | |
# | |
# Sam4s is a trademark of SHIN HEUNG PRECISION CO., LTD., | |
# which have no affiliations with the author (or the existance) of this script | |
# =========================== | |
# Change these values to the text that you want converted | |
strings = [ "My Amazing store", | |
"https://myamazing.store", | |
"INGA ÅTERKÖP!", | |
"NO RETURNS" ] | |
# Change this if you want the character codes to be one per line, etc. | |
separator = " " # For one character per line, change to: "\n", or comma separated: ", " | |
# ----------------------- MAIN CODE (no need to edit!)--------------------------- # | |
# Array with all the "Descriptor codes" for (some) Sam4s cash registers | |
ch_list = { "Ç": "001", "ü": "002", "é": "003", "â": "004", "ä": "005", "à": "006", "å": "007", "ç": "008", "ê": "009", "ë": "010", | |
"è": "011", "ï": "012", "î": "013", "ì": "014", "Ä": "015", "Å": "016", "É": "017", "æ": "018", "Ǽ": "019", "ô": "020", | |
"ö": "021", "ò": "022", "û": "023", "ù": "024", "ÿ": "025", "Ö": "026", "Ü": "027", "¢": "028", "£": "029", "¥": "030", | |
"€": "031", " ": "032", "!": "033", "\"": "034", "#": "035", "$": "036", "%": "037", "&": "038", "'": "039", "(": "040", | |
")": "041", "*": "042", "+": "043", ",": "044", "-": "045", ".": "046", "/": "047", "0": "048", "1": "049", "2": "050", | |
"3": "051", "4": "052", "5": "053", "6": "054", "7": "055", "8": "056", "9": "057", ":": "058", ";": "059", "<": "060", | |
"=": "061", ">": "062", "?": "063", "@": "064", "A": "065", "B": "066", "C": "067", "D": "068", "E": "069", "F": "070", | |
"G": "071", "H": "072", "I": "073", "J": "074", "K": "075", "L": "076", "M": "077", "N": "078", "O": "079", "P": "080", | |
"Q": "081", "R": "082", "S": "083", "T": "084", "U": "085", "V": "086", "W": "087", "X": "088", "Y": "089", "Z": "090", | |
"a": "097", "b": "098", "c": "099", "d": "100", | |
"e": "101", "f": "102", "g": "103", "h": "104", "i": "105", "j": "106", "k": "107", "l": "108", "m": "109", "n": "110", | |
"o": "111", "p": "112", "q": "113", "r": "114", "s": "115", "t": "116", "u": "117", "v": "118", "w": "119", "x": "120", | |
"y": "121", "z": "122", "\x08": "123", } | |
# "": "091", "": "092", "": "093", "": "094", "": "095", "": "096", # <<-- These character codes are not used (as per the manual) | |
# "": "999", # <<-- This "character" (DOUBLE) does not have a matching character in ASCII/UTF-8 | |
# The functiono that does "the work": | |
# Takes a string and outputs the matching character code | |
# The seperator between each character code can be changed by setting the second (seperator) argument (default: [SPACE]) | |
def convert(in_str, separator = " "): | |
print(in_str + ":") | |
for ch in in_str: | |
c = ch_list[ch] | |
print(c, end = separator) | |
print("\n") | |
# Loop through the list of strings to convert | |
for s in strings: | |
convert(s, separator) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment