# Heimdal wind library

## Functions

int | wind_punycode_label_toascii (const uint32_t *in, size_t in_len, char *out, size_t *out_len)
int | wind_stringprep (const uint32_t *in, size_t in_len, uint32_t *out, size_t *out_len, wind_profile_flags flags)
int | wind_profile (const char *name, wind_profile_flags *flags)
int | wind_utf8ucs4 (const char *in, uint32_t *out, size_t *out_len)
int | wind_utf8ucs4_length (const char *in, size_t *out_len)
int | wind_ucs4utf8 (const uint32_t *in, size_t in_len, char *out, size_t *out_len)
int | wind_ucs4utf8_length (const uint32_t *in, size_t in_len, size_t *out_len)
int | wind_ucs2read (const void *ptr, size_t len, unsigned int *flags, uint16_t *out, size_t *out_len)
int | wind_ucs2write (const uint16_t *in, size_t in_len, unsigned int *flags, void *ptr, size_t *out_len)
int | wind_utf8ucs2 (const char *in, uint16_t *out, size_t *out_len)
int | wind_utf8ucs2_length (const char *in, size_t *out_len)
int | wind_ucs2utf8 (const uint16_t *in, size_t in_len, char *out, size_t *out_len)
int | wind_ucs2utf8_length (const uint16_t *in, size_t in_len, size_t *out_len)

## Detailed Description

## Function Documentation

int wind_profile | ( | const char * | name,
|  | wind_profile_flags * | flags |
| ) |  |  |

Try to find the profile given a name.

Parameters:

  | name | name of the profile.
  | flags | the resulting profile.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_punycode_label_toascii | ( | const uint32_t * | in,
|  | size_t | in_len,
|  | char * | out,
|  | size_t * | out_len |
| ) |  |  |

Convert an UCS4 string to a puny-coded DNS label string suitable when combined with delimiters and other labels for DNS lookup.

Parameters:

  | in | an UCS4 string to convert
  | in_len | the length of in.
  | out | the resulting puny-coded string. The string is not NUL terminatied.
  | out_len | before processing out_len should be the length of the out variable, after processing it will be the length of the out string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_stringprep | ( | const uint32_t * | in,
|  | size_t | in_len,
|  | uint32_t * | out,
|  | size_t * | out_len,
|  | wind_profile_flags | flags |
| ) |  |  |

Process a input UCS4 string according a string-prep profile.

Parameters:

  | in | input UCS4 string to process
  | in_len | length of the input string
  | out | output UCS4 string
  | out_len | length of the output string.
  | flags | stringprep profile.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_ucs2read | ( | const void * | ptr,
|  | size_t | len,
|  | unsigned int * | flags,
|  | uint16_t * | out,
|  | size_t * | out_len |
| ) |  |  |

Read in an UCS2 from a buffer.

Parameters:

  | ptr | The input buffer to read from.
  | len | the length of the input buffer.
  | flags | Flags to control the behavior of the function.
  | out | the output UCS2, the array must be at least out/2 long.
  | out_len | the output length

Returns:
  returns 0 on success, an wind error code otherwise.

if len is zero, flags are unchanged

if len is odd, WIND_ERR_LENGTH_NOT_MOD2 is returned

If the flags WIND_RW_BOM is set, check for BOM. If not BOM is found, check is LE/BE flag is already and use that otherwise fail with WIND_ERR_NO_BOM. When done, clear WIND_RW_BOM and the LE/BE flag and set the resulting LE/BE flag.

int wind_ucs2utf8 | ( | const uint16_t * | in,
|  | size_t | in_len,
|  | char * | out,
|  | size_t * | out_len |
| ) |  |  |

Convert an UCS2 string to a UTF-8 string.

Parameters:

  | in | an UCS2 string to convert.
  | in_len | the length of the in UCS2 string.
  | out | the resulting UTF-8 strint, must be at least wind_ucs2utf8_length() long. If out is NULL, the function will calculate the needed space for the out variable (just like wind_ucs2utf8_length()).
  | out_len | before processing out_len should be the length of the out variable, after processing it will be the length of the out string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_ucs2utf8_length | ( | const uint16_t * | in,
|  | size_t | in_len,
|  | size_t * | out_len |
| ) |  |  |

Calculate the length of from converting a UCS2 string to an UTF-8 string.

Parameters:

  | in | an UCS2 string to convert.
  | in_len | an UCS2 string length to convert.
  | out_len | the length of the resulting UTF-8 string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_ucs2write | ( | const uint16_t * | in,
|  | size_t | in_len,
|  | unsigned int * | flags,
|  | void * | ptr,
|  | size_t * | out_len |
| ) |  |  |

Write an UCS2 string to a buffer.

Parameters:

  | in | The input UCS2 string.
  | in_len | the length of the input buffer.
  | flags | Flags to control the behavior of the function.
  | ptr | The input buffer to write to, the array must be at least (in + 1) * 2 bytes long.
  | out_len | the output length

Returns:
  returns 0 on success, an wind error code otherwise.

If in buffer is not of length be mod 2, WIND_ERR_LENGTH_NOT_MOD2 is returned

On zero input length, flags are preserved

If flags have WIND_RW_BOM set, the byte order mark is written first to the output data

If the output wont fit into out_len, WIND_ERR_OVERRUN is returned

int wind_ucs4utf8 | ( | const uint32_t * | in,
|  | size_t | in_len,
|  | char * | out,
|  | size_t * | out_len |
| ) |  |  |

Convert an UCS4 string to a UTF-8 string.

Parameters:

  | in | an UCS4 string to convert.
  | in_len | the length input array.
  | out | the resulting UTF-8 strint, must be at least wind_ucs4utf8_length() + 1 long (the extra char for the NUL). If out is NULL, the function will calculate the needed space for the out variable (just like wind_ucs4utf8_length()).
  | out_len | before processing out_len should be the length of the out variable, after processing it will be the length of the out string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_ucs4utf8_length | ( | const uint32_t * | in,
|  | size_t | in_len,
|  | size_t * | out_len |
| ) |  |  |

Calculate the length of from converting a UCS4 string to an UTF-8 string.

Parameters:

  | in | an UCS4 string to convert.
  | in_len | the length of UCS4 string to convert.
  | out_len | the length of the resulting UTF-8 string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_utf8ucs2 | ( | const char * | in,
|  | uint16_t * | out,
|  | size_t * | out_len |
| ) |  |  |

Convert an UTF-8 string to an UCS2 string.

Parameters:

  | in | an UTF-8 string to convert.
  | out | the resulting UCS2 strint, must be at least wind_utf8ucs2_length() long. If out is NULL, the function will calculate the needed space for the out variable (just like wind_utf8ucs2_length()).
  | out_len | before processing out_len should be the length of the out variable, after processing it will be the length of the out string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_utf8ucs2_length | ( | const char * | in,
|  | size_t * | out_len |
| ) |  |  |

Calculate the length of from converting a UTF-8 string to a UCS2 string.

Parameters:

  | in | an UTF-8 string to convert.
  | out_len | the length of the resulting UCS4 string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_utf8ucs4 | ( | const char * | in,
|  | uint32_t * | out,
|  | size_t * | out_len |
| ) |  |  |

Convert an UTF-8 string to an UCS4 string.

Parameters:

  | in | an UTF-8 string to convert.
  | out | the resulting UCS4 strint, must be at least wind_utf8ucs4_length() long. If out is NULL, the function will calculate the needed space for the out variable (just like wind_utf8ucs4_length()).
  | out_len | before processing out_len should be the length of the out variable, after processing it will be the length of the out string.

Returns:
  returns 0 on success, an wind error code otherwise

int wind_utf8ucs4_length | ( | const char * | in,
|  | size_t * | out_len |
| ) |  |  |

Calculate the length of from converting a UTF-8 string to a UCS4 string.

Parameters:

  | in | an UTF-8 string to convert.
  | out_len | the length of the resulting UCS4 string.

Returns:
  returns 0 on success, an wind error code otherwise