When a Salesforce admin or developer enters a double-byte text string in the Custom Settings Name field, the "Error: Custom Setting Name too long" error can still appear even when the string is much shorter than 38 characters.
Custom Settings is a Salesforce feature that allows administrators to create custom data sets and associate them with an organization, profile, or user. Double-byte characters are characters used in languages such as Chinese, Japanese, and Korean, where each character requires two bytes of storage rather than the single byte used by standard ASCII characters.
This error typically appears when a Custom Setting is created with a name that uses double-byte characters and visually appears well under the 38-character limit. The unexpected behavior occurs because Salesforce internally converts the double-byte string into ASCII format using the Java toASCII() method before applying the limit. That conversion can cause the string length to increase non-linearly, meaning a short-looking input can exceed 38 characters after conversion.
This article answers the question: why does the "Error: Custom Setting Name too long" error appear in the Salesforce Custom Settings Name field when a double-byte name looks shorter than 38 characters, and how do you avoid it? When double-byte characters such as Chinese or Japanese are used in the Custom Settings Name field, Salesforce converts the string to ASCII using the Java toASCII() method before applying the 38-character limit. Because this conversion can increase string length non-linearly, even short double-byte strings may exceed the limit.
If double-byte text is used in the Custom Settings Name field, consider making the text string shorter.
As stated in Define Custom Settings: "The name can't exceed 38 ASCII characters. If you use double byte, there are additional limits on the number of characters allowed."
When double-byte characters are used, the string is converted into ASCII characters by using the Java method toASCII(). The 38-character limit is then applied to the converted ASCII string. As the converted string's length can increase non-linearly, a relatively short input string could be converted to a string longer than 38 characters.
It is recommended to check a given string's converted length by using Java. The following example prints the converted ASCII length of two Chinese strings. The first is within the limit, and the second exceeds the limit.
//Within limit
System.out.println(java.net.IDN.toASCII("一二三四五六七八九十壹贰三").length());
//Exceeding limit
System.out.println(java.net.IDN.toASCII("一二三四五六七八九十壹贰三四").length());
Online Java compiler tools, such as tutorialspoint.com, can be used to run this code.
The character limit for the Name field when creating data for a Custom Setting seems lower when using certain characters.
000397067

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.