Encoding OceanScript
Use the encode() function.
In this function, there is an optional keyword-only argument named “mode”, which can be one of “stretch” or “squash” - defaulting to “squash”.
Stretch mode
Replaces instances of whitespace (” “) with line breaks. This mode is handy for encoding mass amounts of text, or to present oceanscript nicely.
>>> oceanscript.encode('Hello world!', mode='stretch')
'*_-.~-.^>..^>..~>..'
'~-...~>.._>..^>..~<.=!'
Squash mode
Replaces instances of whitespace (” “) with commas. This mode is handy for shorter amounts of text to fit on single lines.
>>> oceanscript.encode('Hello world!', mode='squash')
'*_-.~-.^>..^>..~>..,~-...~>.._>..^>..~<.=!'
Example Usage
>>> text = '1. Bacon\n2. Eggs\n3. Ham'
>>> oceanscript.encode(text)
'^<....=.,*^-.^<.^>.~>..~-..%^-....=.,*~-._<._<.^<...%^>....=.,*_-.^<.~<..'
>>> text = 'Hello my name is Kreusada!'
>>> oceanscript.encode(text, mode='stretch')
'*_-.~-.^>..^>..~>..'
'~<.._<...'
'~-..^<.~<..~-.'
'_>.^<...'
'*^-.._>..~-.^>...^<...^<.~<.^<.=!'