Convert Module
The convert module contains functions to convert between Formal SignWriitng in ASCII (FSW) and SignWriting in Unicode (SWU) characters, along with other types of data.
Characters set definitions: https://datatracker.ietf.org/doc/id/draft-slevinski-formal-signwriting-10.html#name-character-sets
- sutton_signwriting_core.convert.drop_none(d)
Remove key-value pairs from a dictionary where the value is None.
- Parameters:
d (dict[str, T | None]) – Input dictionary with optional values.
- Returns:
Dictionary with same keys and non-None values.
- Return type:
dict[str, T]
Example
>>> drop_none({"a": 1, "b": None, "c": "x"}) {"a": 1, "c": "x"}
- sutton_signwriting_core.convert.to_zoom(zoom)
Convert zoom to float, handling ‘x’ and None.
- Parameters:
zoom (int | float | str | None)
- Return type:
float
- sutton_signwriting_core.convert.swu_to_mark(swu_mark)
Convert an SWU structural marker to FSW equivalent.
- Parameters:
swu_mark (str) – single-character SWU marker
- Returns:
single-letter FSW marker
- Return type:
str
Example
>>> swu_to_mark('𝠀') 'A'
- sutton_signwriting_core.convert.mark_to_swu(fsw_mark)
Convert an FSW structural marker to SWU equivalent.
- Parameters:
fsw_mark (str) – single-letter FSW marker
- Returns:
single-character SWU marker
- Return type:
str
Example
>>> mark_to_swu('A') '𝠀'
- sutton_signwriting_core.convert.swu_to_num(swu_num)
Convert an SWU number character to an integer.
- Parameters:
swu_num (str) – a single SWU number character
- Returns:
integer value
- Return type:
int
Example
>>> swu_to_num('𝤆') 500
- sutton_signwriting_core.convert.num_to_swu(num)
Convert an integer to an SWU number character.
- Parameters:
num (int) – integer
- Returns:
single SWU number character
- Return type:
str
Example
>>> num_to_swu(500) '𝤆'
- sutton_signwriting_core.convert.swu_to_coord(swu_coord)
Convert two SWU number characters to an [x, y] integer list.
- Parameters:
swu_coord (str) – string of two SWU number characters
- Returns:
[x, y] integer list
- Return type:
List[int]
Example
>>> swu_to_coord('𝤆𝤆') [500, 500]
- sutton_signwriting_core.convert.coord_to_swu(coord)
Convert an [x, y] integer list to two SWU number characters.
- Parameters:
coord (List[int]) – [x, y] integer list
- Returns:
string of two SWU number characters
- Return type:
str
Example
>>> coord_to_swu([500, 500]) '𝤆𝤆'
- sutton_signwriting_core.convert.fsw_to_coord(fsw_coord)
Convert an FSW coordinate string to [x, y] integer list.
- Parameters:
fsw_coord (str) – fsw coordinate string
- Returns:
[x, y] integer list
- Return type:
List[int]
Example
>>> fsw_to_coord('500x500') [500, 500]
- sutton_signwriting_core.convert.coord_to_fsw(coord)
Convert an [x, y] list to an FSW coordinate string (‘500x500’).
- Parameters:
coord (List[int]) – [x, y] integer list
- Returns:
fsw coordinate string
- Return type:
str
Example
>>> coord_to_fsw([500, 500]) '500x500'
- sutton_signwriting_core.convert.swu_to_code(swu_sym)
Convert an SWU symbol character to its Unicode code point.
- Parameters:
swu_sym (str) – SWU symbol character
- Returns:
integer codepoint
- Return type:
int
Example
>>> swu_to_code('') 0x40001
- sutton_signwriting_core.convert.code_to_swu(code)
Convert a codepoint on plane 4 to an SWU symbol character.
- Parameters:
code (int) – integer codepoint
- Returns:
SWU symbol character
- Return type:
str
Example
>>> code_to_swu(0x40001) ''
- sutton_signwriting_core.convert.swu_to_id(swu_sym)
Convert an SWU symbol character to a 16-bit ID.
- Parameters:
swu_sym (str) – SWU symbol character
- Returns:
16-bit ID
- Return type:
int
Example
>>> swu_to_id('') 1
- sutton_signwriting_core.convert.id_to_swu(id_)
Convert a 16-bit ID to an SWU symbol character.
- Parameters:
id – 16-bit ID
id_ (int)
- Returns:
SWU symbol character
- Return type:
str
Example
>>> id_to_swu(1) ''
- sutton_signwriting_core.convert.key_to_id(key)
Convert an FSW symbol key to a 16-bit ID.
- Parameters:
key (str) – FSW symbol key
- Returns:
16-bit ID
- Return type:
int
Example
>>> key_to_id('S10000') 1
- sutton_signwriting_core.convert.id_to_key(id_)
Convert a 16-bit ID to an FSW symbol key.
- Parameters:
id – 16-bit ID
id_ (int)
- Returns:
FSW symbol key
- Return type:
str
Example
>>> id_to_key(1) 'S10000'
- sutton_signwriting_core.convert.swu_to_key(swu_sym)
Convert an SWU symbol character to an FSW symbol key.
- Parameters:
swu_sym (str) – SWU symbol character
- Returns:
FSW symbol key
- Return type:
str
Example
>>> swu_to_key('') 'S10000'
- sutton_signwriting_core.convert.key_to_swu(key)
Convert an FSW symbol key to an SWU symbol character.
- Parameters:
key (str) – FSW symbol key
- Returns:
SWU symbol character
- Return type:
str
Example
>>> key_to_swu('S10000) ''
- sutton_signwriting_core.convert.swu_to_fsw(swu_text)
Convert SWU text to FSW text.
- Parameters:
swu_text (str) – SWU text string
- Returns:
SWU text string
- Return type:
str
Example
>>> swu_to_fsw('𝠀𝠃𝤟𝤩𝣵𝤐𝤇𝣤𝤐𝤆𝣮𝣭') 'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'
- sutton_signwriting_core.convert.fsw_to_swu(fsw_text)
Convert FSW text to SWU text.
- Parameters:
fsw_text (str) – FSW text string
- Returns:
SWU text string
- Return type:
str
Example
>>> fsw_to_swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475') '𝠀𝠃𝤟𝤩𝣵𝤐𝤇𝣤𝤐𝤆𝣮𝣭'
- sutton_signwriting_core.convert.symid_max(symid_min)
Convert base or full symbol ID Min to symbol ID Max.
- Parameters:
symid_min (str) – minimized symbol ID
- Returns:
maximized symbol ID
- Return type:
str
Examples
>>> symid_max('101011') '01-01-001-01' >>> symid_max('101011616') '01-01-001-01-06-16'
- sutton_signwriting_core.convert.symid_min(symid_max)
Convert base or full symbol ID Max to symbol ID Min.
- Parameters:
symid_max (str) – maximized symbol ID
- Returns:
minimized symbol ID
- Return type:
str
Examples
>>> symid_min('01-01-001-01') '101011' >>> symid_min('01-01-001-01-06-16') '101011616'
- sutton_signwriting_core.convert.symid_to_key(symid)
Convert base or full symbol ID max to FSW symbol key.
- Parameters:
symid (str) – base of full maximized symbol ID
- Returns:
FSW symbol key
- Return type:
str
Examples
>>> symid_to_key('01-01-001-01') 'S100' >>> symid_to_key('01-01-001-01-06-16') 'S1005f'
- sutton_signwriting_core.convert.key_to_symid(key)
Convert base or full FSW symbol key to maximized symbol ID.
- Parameters:
key (str) – FSW symbol key
- Returns:
maximized symbol ID
- Return type:
str
Examples
>>> key_to_symid('S100') '01-01-001-01' >>> key_to_symid('S1005f') '01-01-001-01-06-16'