![]() |
libtld 2.0.14
A library to determine the Top-Level Domain name of any Internet URI.
|
Force lowercase for all characters in the domain name. More...
#include "libtld/tld.h"
#include "tld_data.h"
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
Go to the source code of this file.
Functions | |
static int | tld_byte_in (const char **s) |
Read one byte of data. | |
static int | tld_byte_out (char **s, int *max_length, char byte) |
The tld_byte_out() outputs a character. | |
static int | tld_dec2hex (int d) |
Transform a number to a hexadecimal digit. | |
char * | tld_domain_to_lowercase (const char *domain) |
Transform a domain with a TLD to lowercase before processing. | |
static int | tld_hex2dec (char c) |
Transform a hexadecimal digit to a number. | |
static wint_t | tld_mbtowc (const char **s) |
Transform a multi-byte UTF-8 character to a wide character. | |
static int | tld_wctomb (wint_t wc, char **s, int *max_length) |
Convert a wide character to UTF-8. | |
This file includes the functions used to convert a domain name from whatever case it comes in as to lowercase only. The input domain name is expected to still be URL encoded and be valid UTF-8.
Definition in file tld_domain_to_lowercase.c.
|
static |
The tld_byte_in() function reads one byte. The byte may either be a XX or a plain byte. The input may be UTF-8 characters.
The input pointer (s
) get incremented automatically as required.
[in] | s | The pointer to a string pointer where the byte the read is. |
Definition at line 115 of file tld_domain_to_lowercase.c.
References tld_hex2dec().
Referenced by tld_mbtowc().
|
static |
This function ensures that the byte being output is properly defined according to URI encoding rules. This means all the characters get converted to XX except the few that can be encoded as is (i.e. some of the ASCII characters.)
[in,out] | s | The output string where the character is saved. |
[in,out] | max_length | The length of s, adjusted each time s is incremented. |
[in] | byte | The byte to output in s. |
Definition at line 166 of file tld_domain_to_lowercase.c.
References tld_dec2hex().
Referenced by tld_wctomb().
|
static |
This function transforms the specified number in a hexadecimal digit. The number must be a value between 0 and 15.
[in] | d | A number from 0 to 15 to convert to a hexadecimal digit. |
Definition at line 92 of file tld_domain_to_lowercase.c.
Referenced by tld_byte_out().
char * tld_domain_to_lowercase | ( | const char * | domain | ) |
This function will transform the input domain name to lowercase. You should call this function before you call the tld() function to make sure that the input data is in lowercase.
This function interprets the XX input data and transforms that to characters. The function further converts UTF-8 characters to wide characters to be able to determine the lowercase version.
In C++ you may use an std::unique_ptr<> with free as the deleter to not have to bother with the call by hand (especially if you have possible exceptions in your code):
[in] | domain | The input domain to convert to lowercase. |
Definition at line 489 of file tld_domain_to_lowercase.c.
References tld_mbtowc(), and tld_wctomb().
Referenced by tld_email_list::tld_email_t::parse().
|
static |
This function transforms the specified character c
to a number from 0 to 15.
The function supports upper and lower case.
[in] | c | An hexadecimal character to transform to a number. |
Definition at line 61 of file tld_domain_to_lowercase.c.
Referenced by tld_byte_in().
|
static |
This function transforms a UTF-8 encoded character, which may use 1 to 4 bytes, to a wide character (31 bit).
[in] | s | A pointer to string with possible UTF-8 bytes. |
Definition at line 298 of file tld_domain_to_lowercase.c.
References tld_byte_in().
Referenced by tld_domain_to_lowercase().
|
static |
This function quickly transforms a wide character to UTF-8. The output buffer is pointed by s and has max_length byte left for output.
The function returns -1 if the character cannot be converted. There are the main reasons for failure:
The function automatically adjusts the output buffer and max_length parameters.
[in] | wc | The wide character to convert |
[in,out] | s | The pointer to the output string pointer. |
[in,out] | max_length | The size of the output string buffer. |
Definition at line 388 of file tld_domain_to_lowercase.c.
References tld_byte_out().
Referenced by tld_domain_to_lowercase().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.