
Nameprep is a crucial process in the ICU, where it helps to normalize and prepare names for use in various applications.
It's designed to handle a wide range of input, including ASCII, Unicode, and other character sets.
Nameprep ensures that names are in a consistent format, which is essential for accurate identification and record-keeping.
The process involves several steps, including case folding, normalization, and removal of certain characters.
Expand your knowledge: What Is a Web Domain Names
What is Nameprep
Nameprep is a process that prepares a string for use in domain names by case-folding it to lowercase and removing some generally invisible code points.
It's used by the Internationalizing Domain Names in Applications (IDNA) standard, which relies on the Unicode standard for NFKC normalization.
Nameprep is defined in RFC 3491, "Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)", as a profile of stringprep, which is described in RFC 3454, "Preparation of Internationalized Strings ("stringprep")".
This process doesn't map lookalike characters to a single character, nor does it prohibit the use of lookalike characters, which can have implications for security if not considered by system designers and administrators.
The main goal of Nameprep is to prepare a string for use in domain names, making it suitable for representation.
Preparation Process
The NamePrep profile is a crucial part of the IDNA preparation process, and it's defined in RFC 3491.
To prepare a string, NamePrep follows a specific set of rules, which include mapping, normalizing, prohibiting, and checking for bidirectional code points. The mapping rule includes all code point mappings specified in StringPrep.
The StringPrep service in ICU is data-driven and uses the Open-Use-Close pattern. It's based on a profile that's opened, processed, and then closed. The service is designed for optimum performance, with profile data files being memory mapped and cached.
Here are the steps to produce a StringPrep profile data file:
- Run filterRFC3454.pl Perl tool to filter the RFC file and produce a rule file.
- Run the gensprep tool to compile the rule file into a binary format with options for normalization and bidirectional checking.
- Open the StringPrep profile with the path to the binary and name of the binary profile file as options.
Mapping
Mapping is a crucial step in the preparation process, and it's where we apply specific rules to ensure our internationalized strings are in the correct format.
The NamePrep profile, defined in RFC 3491, specifies mapping rules that include code point mappings from StringPrep.
These mappings are used to transform the input string into a standardized form.
According to the NamePrep profile, all code point mappings specified in StringPrep should be included in the mapping process.
Here are the specific rules for mapping:
- Include all code point mappings specified in StringPrep.
- Prohibit all code points specified as prohibited in StringPrep, except for the space (U+0020) code point.
In the A.3. Mapping section, the profile references tables from the StringPrep specification to determine the mapping rules.
The tables from [STRINGPREP] are used to specify the mapping rules for different character types.
By applying these mapping rules, we can ensure that our internationalized strings are properly formatted for use in IDNA.
Localpart
A localpart is an optional identifier placed before the domainpart in a JID, separated by the '@' character.
It typically identifies the entity requesting and using network access provided by a server, but can also represent other kinds of entities like a chat room.
The localpart MUST be formatted such that the Nodeprep profile of [STRINGPREP] can be applied without failing.
This means that before comparing two localparts, an application MUST first ensure that the Nodeprep profile has been applied to each identifier.
A localpart MUST NOT be zero bytes in length and MUST NOT be more than 1023 bytes in length.
This rule is enforced after any mapping or normalization resulting from application of the Nodeprep profile.
IDNA API in ICU

ICU provides APIs for performing the ToASCII, ToUnicode and compare operations as defined by the RFC 3490. These APIs are specifically designed for string manipulation and follow ICU's coding guidelines.
The APIs provided by ICU are a convenient way to perform IDN comparisons. Convenience methods for comparing IDNs are also offered by ICU.
ICU's IDNA API is a valuable resource for developers working with internationalized domain names.
Parameters and Return Value
The dwFlags parameter is where you specify conversion options for the Nameprep processing. It's worth noting that the function can return NULL for the lpNameprepCharStr parameter if cchNameprepChar is set to 0.
The lpNameprepCharStr parameter is a pointer to a buffer that receives the converted Unicode string. This buffer can be NULL if cchNameprepChar is 0, in which case the function returns the required buffer size.
The cchNameprepChar parameter specifies the size of the buffer indicated by lpNameprepCharStr. If this size is 0, the function will return NULL in lpNameprepCharStr and the required buffer size.

If the function succeeds and cchNameprepChar is 0, it returns the required size, including a terminating null character if it was part of the input buffer. Otherwise, it returns the number of characters retrieved in lpNameprepCharStr.
Here are the possible return values and their meanings:
- 0: The function did not succeed.
- Required size: The function succeeded and cchNameprepChar was 0.
- Number of characters retrieved: The function succeeded and cchNameprepChar was not 0.
Prohibited Output
Prohibited Output is a crucial aspect of Parameters and Return Value. This section specifies the prohibition of using certain tables from the [STRINGPREP] standard.
The tables in question come from "Preparation of Internationalized Strings ("stringprep")" by Hoffman and Blanchet, published in December 2002. These tables are not to be used.
In addition to the prohibited tables, certain Unicode characters are also off-limits. These characters are not specified by name, but their prohibition is clearly stated.
Parameters
dwFlags is a parameter that specifies conversion options. It's a crucial part of the function, and for detailed definitions, you should see the dwFlags parameter of IdnToAscii.
The input parameter lpUnicodeCharStr is a pointer to a Unicode string representing an IDN or another internationalized label. This string is the foundation of the function's work.

cchUnicodeChar is a count of Unicode characters in the input Unicode string indicated by lpUnicodeCharStr. It's essential to get this number right to ensure accurate results.
lpNameprepCharStr is a pointer to a buffer that receives a version of the input Unicode string converted through NamePrep processing. This buffer can also be NULL if cchNameprepChar is set to 0.
cchNameprepChar is a size, in characters, of the buffer indicated by lpNameprepCharStr. If you set this size to 0, the function will return the required buffer size instead of filling the buffer.
Return Value
The return value of this function can be a bit tricky to understand, but don't worry, I've got you covered. It returns the number of characters retrieved in lpNameprepCharStr if successful.
If the function succeeds and the value of cchNameprepChar is 0, it returns the required size in characters, including a terminating null character if it was part of the input buffer. This is important to note, as it affects how you handle the returned string.

The function returns 0 if it doesn't succeed, which means something went wrong. To get more information about what went wrong, you can call GetLastError, which can return one of the following error codes:
- ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
- ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
- ERROR_INVALID_NAME. An invalid name was supplied to the function. Note that this error code catches all syntax errors.
- ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
- ERROR_NO_UNICODE_TRANSLATION. Invalid Unicode was found in a string.
Internationalization Considerations
XMPP servers MUST support IDNA2003 for domain parts, which enables XMPP addresses to include a wide variety of characters outside the US-ASCII range.
IDNA2003 is used in conjunction with the NAMEPREP profile of STRINGPREP, which is a stringprep profile for internationalized domain names.
XMPP clients SHOULD support IDNA2003 for domain parts, as well as the Nodeprep and Resourceprep profiles of STRINGPREP, which are used for localparts and resourceparts, respectively.
Terminology
Many important terms used in this document are defined in external references, including IDNA2003, STRINGPREP, UNICODE, and XMPP.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" have specific meanings as described in RFC 2119.
All JIDs are based on a specific structure.

The feature set specified here attempts to adhere to the concepts and formats proposed by Larry Masinter in 2005, as captured in INTEROP.
This feature set provides a suitable basis for the generation of implementation reports to be submitted in support of advancing this specification from Proposed Standard to Draft Standard in accordance with PROCESS.
Design Considerations
Design Considerations are crucial when it comes to internationalization, and StringPrep profiles have some unique characteristics that are worth noting. They contain information about code points, and can even add or delete code points or mappings.
StringPrep profiles have properties such as turning normalization and checking for bidirectional code points on or off. These properties are important to consider when designing a StringPrep profile.
Here are some key characteristics of StringPrep profiles:
- Contain information about code points
- Allow adding or deleting code points or mappings
- Have properties such as normalization and bidirectional code point checking
- Do not change once defined
The StringPrep algorithm itself is not overridden by the profile, which is an important consideration for developers.
Internationalization Considerations
Internationalization Considerations are crucial in XMPP, allowing for a wide variety of characters outside the US-ASCII range in XMPP addresses.
XMPP servers must support IDNA2003 for domainparts, including the NAMEPREP profile of STRINGPREP, to enable internationalized domain names.
XMPP clients should also support IDNA2003 for domainparts, as well as the Nodeprep and Resourceprep profiles of STRINGPREP, to enable internationalized local and resource parts.
The rules for enforcing the XMPP address format are provided in the XMPP Core specification.
To ensure proper internationalization, an implementation must not enable a human user to input Unicode code points whose decomposition includes prohibited characters, including U+2100 (ACCOUNT OF) and U+226E (NOT LESS-THAN).
Here are some specific Unicode code points that should be prohibited:
Related Profiles and RFCs
If you're interested in learning more about the Nameprep protocol, you might also want to check out the related profiles and RFCs.
The Unicode Technical Standard #31 (UTS31) is closely related to Nameprep, as it provides a set of guidelines for preparing internationalized strings for use in protocols.
The IETF RFC 5891 defines the Unicode IDNA Compatibility Processing, which is used in conjunction with Nameprep.
The IETF RFC 5892 defines the Unicode IDNA Table Registry, which is also related to Nameprep.
Domain and Resource Parts
The domain and resource parts of a JID are crucial components that help identify an entity in the XMPP network. A domainpart is an identifier that typically represents a domain, while a resourcepart is an optional identifier that can modify either a domainpart or a localpart@domainpart address.
A resourcepart is formatted such that the Resourceprep profile of [STRINGPREP] can be applied without failing. This means it must be between 1 and 1023 bytes in length and not zero bytes in length after any mapping or normalization.
XMPP entities should consider resourceparts as opaque strings and not impute any meaning to them. The '/' character is used as a separator between the domainpart and the resourcepart, but it doesn't imply a hierarchical structure.
Domain Part
The Domain Part is the core of any web application, responsible for managing business logic and data.
A Domain Model is a conceptual representation of the Domain Part, which helps developers understand the relationships between different entities and processes.
Domain Models can be simple or complex, depending on the application's requirements.
In a typical Domain Model, you'll find Entities, which are objects that represent real-world concepts, such as customers or orders.
Entities can have Attributes, which are properties that describe the Entity, like name, email, or address.
The Domain Part is also responsible for defining the Business Rules that govern the application's behavior.
Business Rules dictate how the application should behave in different scenarios, such as validating user input or calculating totals.
A well-designed Domain Part can significantly improve the maintainability and scalability of the application.
Nodeprep and Stringprep
The Nodeprep profile of stringprep is defined under Nodeprep. It's a crucial part of the XMPP protocol, which is used for instant messaging and other real-time communication services.
The security considerations described in [STRINGPREP] apply to the Nodeprep profile defined in this document for XMPP localparts and resourceparts. This shows that security is a top priority when it comes to Nodeprep.
Nodeprep is a profile of stringprep, which was registered in the "Stringprep Profiles" registry by the IANA. This highlights the importance of standardization in the tech industry.
The IANA has registered Nodeprep, which means it's a widely accepted and used standard. This is a big deal in the world of tech, where standards can make or break a protocol.
The Nameprep profile that is reused here for XMPP domainparts applies the security considerations described in [STRINGPREP] and [NAMEPREP]. This shows that Nameprep is built on top of established security protocols.
Featured Images: pexels.com


