Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rmqrcode/encoder/alphanumeric_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ def characters_num(cls, data):

@classmethod
def is_valid_characters(cls, data):
return bool(re.match(r"^[0-9A-Z\s\$\%\*\+\-\.\/\:]*$", data))
return all((char in cls.CHARACTER_MAP.keys() for char in data))
6 changes: 3 additions & 3 deletions src/rmqrcode/encoder/kanji_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def _encoded_bits(cls, data):
shift_jis = c.encode("shift-jis")
hex_value = shift_jis[0] * 256 + shift_jis[1]

if hex_value >= 0x8140 and hex_value <= 0x9FFC:
if 0x8140 <= hex_value <= 0x9FFC:
sub = 0x8140
elif hex_value >= 0xE040 and hex_value <= 0xEBBF:
elif 0xE040 <= hex_value <= 0xEBBF:
sub = 0xC140
else:
raise IllegalCharacterError()
Expand Down Expand Up @@ -44,6 +44,6 @@ def is_valid_characters(cls, data):
if len(shift_jis) < 2:
return False
hex_value = shift_jis[0] * 256 + shift_jis[1]
if (0x8140 > hex_value and 0x9FFC < hex_value) or (0xE040 > hex_value and 0xEBBF < hex_value):
if hex_value < 0x8140 or 0x9FFC < hex_value < 0xE040 or 0xEBBF < hex_value:
return False
return True
2 changes: 1 addition & 1 deletion src/rmqrcode/encoder/numeric_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def characters_num(cls, data):

@classmethod
def is_valid_characters(cls, data):
return bool(re.match(r"^[0-9]*$", data))
return all((char in "0123456789" for char in data))