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

Support for idn/punnycode #18

Closed
schochastics opened this issue Sep 24, 2023 · 2 comments
Closed

Support for idn/punnycode #18

schochastics opened this issue Sep 24, 2023 · 2 comments
Assignees
Labels

Comments

@schochastics
Copy link
Member

A problem in #17 is the decoding of idn/punnycode.
There are Pointers in the ada code to support that but this needs further investigation

@schochastics schochastics self-assigned this Sep 24, 2023
@schochastics
Copy link
Member Author

This function

ada_owned_string ada_idna_to_unicode(const char* input, size_t length) {
  std::string out = ada::idna::to_unicode(std::string_view(input, length));
  ada_owned_string owned{};
  owned.length = out.length();
  owned.data = new char[owned.length];
  memcpy((void*)owned.data, out.data(), owned.length);
  return owned;
}

@schochastics
Copy link
Member Author

this should do the trick

std::string charsub(ada_string stringi){

  const char* res = stringi.data;
  size_t len = stringi.length;
  ada_owned_string stringi_new = ada_idna_to_unicode(res,len);
  res = stringi_new.data;
  len = stringi_new.length;
  return std::string(res, 0, len); 
}

This was referenced Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant