[chirp_devel] [PATCH] [ic208] Fix charset and char encoding
Marco Filippi IZ3GME
Tue Jun 4 17:27:47 PDT 2013
# HG changeset patch
# User Marco Filippi <iz3gme.marco at gmail.com>
# Date 1370392000 -7200
# Node ID 2c93325986020188eacc6a3dcee5962bf20fa78d
# Parent 1cb00a7ec7e12a3f58e6ada992c9a671690be690
[ic208] Fix charset and char encoding
Fix bug #889
diff -r 1cb00a7ec7e1 -r 2c9332598602 chirp/ic208.py
--- a/chirp/ic208.py mar giu 04 13:00:23 2013 +0200
+++ b/chirp/ic208.py mer giu 05 02:26:40 2013 +0200
@@ -75,18 +75,16 @@
IC208_SPECIAL.append("%iA" % i)
IC208_SPECIAL.append("%iB" % i)
-ALPHA_CHARSET = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-NUMERIC_CHARSET = "0123456789+-=*/()|"
+CHARSET = dict(zip([0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0f], " ()*+-/") +
+ zip(range(0x10, 0x1a), "0123456789") +
+ [(0x1c,'|'), (0x1d,'=')] +
+ zip(range(0x21, 0x3b), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
+CHARSET_REV = dict(zip(CHARSET.values(), CHARSET.keys()))
def get_name(_mem):
"""Decode the name from @_mem"""
def _get_char(val):
- if val == 0:
- return " "
- elif val & 0x20:
- return ALPHA_CHARSET[val & 0x1F]
- else:
- return NUMERIC_CHARSET[val & 0x0F]
+ return CHARSET[int(val)]
name_bytes = [_mem.name1, _mem.name2, _mem.name3,
_mem.name4, _mem.name5, _mem.name6]
@@ -99,12 +97,7 @@
def set_name(_mem, name):
"""Encode @name in @_mem"""
def _get_index(char):
- if char == " ":
- return 0
- elif char.isalpha():
- return ALPHA_CHARSET.index(char) | 0x20
- else:
- return NUMERIC_CHARSET.index(char) | 0x10
+ return CHARSET_REV[char]
name = name.ljust(6)[:6]
@@ -148,6 +141,7 @@
(230000000, 550000000),
(810000000, 999995000)]
rf.valid_special_chans = ["C1", "C2"] + sorted(IC208_SPECIAL)
+ rf.valid_characters = "".join(CHARSET.values())
return rf
def get_raw_memory(self, number):
More information about the chirp_devel
mailing list