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

Added example UTF-8 conversion functions #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ocrow
Copy link

@ocrow ocrow commented Aug 31, 2016

Added push_utf8_string() and get_utf8_string() functions that implement the suggested encoding/decoding of surrogate pairs when passing UTF8 strings in to or out of duktape.

I'm not sure if this is the right place to put these functions. Would they be better as C source somewhere in the duktape distribution? The bit-twiddling required was involved enough that it seems worth sharing this code.

Added push_utf8_string() and get_utf8_string() functions that implement the suggested encoding/decoding of surrogate pairs when passing UTF8 strings in to or out of duktape.
@svaarala
Copy link
Owner

I'll comment on the content itself separately, but regarding placement: having this in the Wiki is fine and the page you chose seems best for the purpose.

If the code were in Duktape repo, there'd be two logical places:

  • examples/ if the code is intended to be just an example and not maintained and/or production quality
  • extras/ if the code is maintained and production quality

There's no crystal clear policy now for what kind of code should go into Duktape repo/distributable. It makes sense when the code is somehow Duktape version relevant and/or very close to the core functionality (e.g. the module loader implementations) and/or encountered very commonly in user code (e.g. allocators). String encoding/decoding stuff fits the latter criteria I think and there's already a codepage conversion utility in the examples/ directory.

Finally, you could put the code in a separate repo and the Wiki could link there.

Code which is inline in the Wiki articles should naturally explain or illustrate the text surrounding it. For code which is useful but doesn't necessarily fit that purpose (e.g. it is long or very technical and not illustrative w.r.t. the surrounding text) linking may be a better idea.

@ocrow
Copy link
Author

ocrow commented Sep 1, 2016

Putting it in examples/ seems perhaps most appropriate. I'll put together some test code to demonstrate the functionality and resubmit.

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

Successfully merging this pull request may close these issues.

2 participants