help-libidn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libidn2 0.13


From: Tim Ruehsen
Subject: Re: libidn2 0.13
Date: Mon, 09 Jan 2017 14:35:31 +0100
User-agent: KMail/5.2.3 (Linux/4.8.0-2-amd64; KDE/5.28.0; x86_64; ; )

On Sunday, January 8, 2017 2:28:33 PM CET Simon Josefsson wrote:
> Den Sat, 07 Jan 2017 19:48:42 +0100
> 
> skrev Re: libidn2 0.13:
> > On Dienstag, 3. Januar 2017 10:00:53 CET Nikos Mavrogiannopoulos
> > 
> > wrote:
> > > On Mon, Jan 2, 2017 at 10:17 PM, Tim Rühsen <address@hidden>
> > > 
> > > wrote:
> > > >> * APIs more like libidn's that take a full domain name and do
> > > >> proper
> > > >> 
> > > >>   operations on them.  In several forms, UTF-8, USC-32, locale
> > > >> 
> > > >> encoded, etc.
> > > >> 
> > > >> * APIs to decode a IDNA2008 domain from ACE to Unicode format.
> > > >> That is
> > > >> 
> > > >>   not described by the IDNA2008 RFCs, interestingly enough, but I
> > > >>   suspect people will want it, hah!
> > > > 
> > > > Wget used to use ACE decoding from libidn, but only for
> > > > logging/displaying purpose. Since we switched to libidn2, the
> > > > UTF-8/locale named will not be displayed any more :-). With such
> > > > a function I would reactivate the logging
> > > > code.
> > > 
> > > For gnutls unfortunately the reverse is really necessary and that's
> > > the reason we are stuck with libidn. We need to be able to print the
> > > actual name of the certificate and not only the punycode which is
> > > non-human readable for most languages.
> > 
> > Than let's define a function.
> > 
> > Let me start with a suggestion to get the ball rolling
> > 
> >     int idn2_fromASCII (const uint8_t *src, uint8_t **dst)
> > 
> > 'src' is an UTF-8 encoded string (domain name)
> > 'dst' is the punycode-decoded output, also UTF-8.
> 
> How about copying the libidn APIs?  Here are the low-level per-label
> primitives:
> 
>   /* Core functions */
>   extern IDNAPI int idna_to_ascii_4i (const uint32_t * in, size_t inlen,
>                                     char *out, int flags);
>   extern IDNAPI int idna_to_unicode_44i (const uint32_t * in, size_t
>   inlen, uint32_t * out, size_t * outlen,
>                                        int flags);
> 
> The idna_to_ascii_4i call is roughly equivalent to idn2_lookup.
> idna_to_unicode doesn't exist in libidn2.
> 
> Then the interesting APIs for applications:
> 
>   extern IDNAPI int idna_to_ascii_4z (const uint32_t * input,
>                                     char **output, int flags);
> 
>   extern IDNAPI int idna_to_ascii_8z (const char *input, char **output,
>                                     int flags);
> 
>   extern IDNAPI int idna_to_ascii_lz (const char *input, char **output,
>                                     int flags);
> 
>   extern IDNAPI int idna_to_unicode_4z4z (const uint32_t * input,
>                                         uint32_t ** output, int
>   flags);
> 
>   extern IDNAPI int idna_to_unicode_8z4z (const char *input,
>                                         uint32_t ** output, int
>   flags);
> 
>   extern IDNAPI int idna_to_unicode_8z8z (const char *input,
>                                         char **output, int flags);
> 
>   extern IDNAPI int idna_to_unicode_8zlz (const char *input,
>                                         char **output, int flags);
> 
>   extern IDNAPI int idna_to_unicode_lzlz (const char *input,
>                                         char **output, int flags);
> 
> 
> Mimicking these APIs are probably what's interesting.

I thought about the libidn to_unicode API again...
(Just another approach for discussion.)

We could provide a generic conversion API plus some convenience wrappers like 
the above functionality.

Example:
IDN_DECODER *idn_decoder_open(flags)
int idn_decoder_set_input_encoding(IDN_DECODER *idn, const char *encoding)
  // encoding == NULL: input is encoded with local encoding (default)
int idn_decoder_set_input(IDN_DECODER *idn, const char *in, ssize_t len)
  // len == -1: use strlen()
int idn_decoder_set_output_encoding(IDN_DECODER *idn, const char *encoding)
  // encoding == NULL: input is encoded with local encoding (default)
int idn_decoder_get_output(IDN_DECODER *idn, char **out, size_t **len)
void idn_decoder_close(IDN_DECODER **idn)
  // **idn to automate NULLifing *idn after freeing

That allows to add more set/get or other API stuff later if needed.
And we can easily mimic all the above mentioned idna_ (convenience) functions.

Regards, Tim

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]