Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Enhance map->query with an escape hatch for a different encoder #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

iku000888
Copy link

Problem: Cannot use any encoding other than utf-8
Solution: Make the fn aware of a special keyword where the value is a fn used for encoding instead of the default one.

@cemerick
Copy link
Owner

If you're actually looking to perform URL encoding using a different character encoding, then the proper way would be for map->query to accept an optional encoding argument that is then passed along to url-encode.

@iku000888
Copy link
Author

Thanks for the feedback and your time!

I would like to clarify the motivation:

  1. What I really need is to URL encode with the Apache Commons Codec library with Shift_JIS encoding (because the Java one won't encode Shift_JIS correctly), so I need to be able to pass in an encoder function rather than an encoding option that the java.net.URLEncoder will use.

  2. Being able to just assoc a function with a designated keyword in an existing map when needed is really convenient if map->query has already been wrapped with n different layers of functions. (Alas, that has been done with my project...)

Would your suggestion still be the same?

Thanks for your time again!

@iku000888
Copy link
Author

@cemerick what do you think?

@iku000888
Copy link
Author

@cemerick

  1. I changed map->query so that it accepts an additional encoding argument as per your suggestion.
  2. I turned url-encode into a multimethod so that consumers of this library can plug in an arbitrary encoder.
  3. The default behaviour of map->query does not change.

Appreciate your feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants