Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode and decode string #251

Open
GammaGames opened this issue Jun 22, 2018 · 0 comments
Open

Encode and decode string #251

GammaGames opened this issue Jun 22, 2018 · 0 comments

Comments

@GammaGames
Copy link

I think it might be useful to have functions to encode and decode strings. If this functionality was to be added, it could take the format of .d<str><str> and .D<str><str>. The first argument is the string and the second argument is the encoding (taken from the standard encodings).

For example, to encode the input into cp1252, you would write .dQ"cp1252, and to decode the input intp cp1252 you would write .DQ"cp1252. Using the character k as the second argument would use the default encoding, UTF-8.

So, to do this code golf with the python code:

from codecs import *
decode(encode('I ♥ UTF-8'),'cp1252')
===========
'I ♥ UTF-8'

you would write .D.dQk"cp1252.

I know the feature is obscure, but I think it might be useful in creative string-based golfs.

@GammaGames GammaGames changed the title Encode and decode Encode and decode string Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant