-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Social SDK] New How-To section + Handling special characters in Display Names guide #7621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| sidebar_label: How To | ||
| showTOC: false | ||
| subpages: | ||
| - how-to/handle-special-characters-display-names.mdx | ||
| --- | ||
|
|
||
| [Home](/docs/intro) > [Discord Social SDK](/docs/discord-social-sdk/overview) > How To | ||
|
|
||
| # Discord Social SDK How To Guides | ||
|
|
||
| These how-to guides offer common solutions for integrating Discord Social SDK features into your game. | ||
|
|
||
| <Container> | ||
| <Card title="Handle Special Characters in Display Names" link="/docs/discord-social-sdk/how-to/handle-special-characters-display-names" icon="LettersIcon"> | ||
| Handling Unicode characters in Discord Display Names for your game's chat and friend lists. | ||
| </Card> | ||
| </Container> | ||
|
|
||
| --- | ||
|
|
||
| ## Change Log | ||
|
|
||
| | Date | Changes | | ||
| |---------------|-----------------------| | ||
| | June 17, 2025 | added How To category | |
49 changes: 49 additions & 0 deletions
49
docs/discord-social-sdk/how-to/handle-special-characters-display-names.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| --- | ||
| sidebar_label: Handle Special Characters in Display Names | ||
| --- | ||
|
|
||
| [Home](/docs/intro) > [Discord Social SDK](/docs/discord-social-sdk/overview) > [How To](/docs/discord-social-sdk/how-to) > {sidebar_label} | ||
|
|
||
| # How To {sidebar_label} | ||
|
|
||
| The Social SDK [recommends](https://discord.com/developers/docs/discord-social-sdk/development-guides/creating-a-unified-friends-list#step-1-fetch-relationships) using an account's [Display Name](https://discord.com/developers/docs/slayer-sdk/classdiscordpp_1_1UserHandle.html#af6447fa2011bfa4fcd7e55bc56847f5c) in the Unified Friends List. However, Display Names support a large set of characters across the Unicode spec, and some of these characters may not be supported in a game's specified font. | ||
|
|
||
| There are several options to address this: | ||
|
|
||
| ## 1. Map the Unicode characters to ASCII | ||
|
|
||
| A library such as [Unidecode](https://metacpan.org/pod/Text::Unidecode) (which has been ported to many different languages) can map many Unicode characters to an ASCII equivalent. If you detect that a Display Name has characters that cannot be rendered, consider passing it through a library to transliterate the Display Name to ASCII. | ||
|
|
||
| **Tradeoffs:** | ||
|
|
||
| - This may result in unintended transliterations. It is impossible to create a perfect mapping between Unicode and ASCII in every situation. Libraries try their best, but this approach may unintentionally create an inaccurate or even offensive display name in some instances. | ||
| - Libraries will not have 100% coverage. Some Unicode characters may not have a map to an ASCII character. If someone's Display Name is `ʕ•͡-•ʔ` what would it map to? | ||
| - Similarly, most libraries assume English is the target language. | ||
| - Users may not appreciate their display names being changed without their knowledge or consent. | ||
|
|
||
| ## 2. Use a font family that supports Unicode | ||
|
|
||
| A family such as [Noto](https://notofonts.github.io/) aims to have broad Unicode support. If a font cannot render a Display Name, consider rendering it with a fallback font, or in the extreme case, choose a font with broad Unicode support for the Friends List. | ||
|
|
||
| **Tradeoffs:** | ||
|
|
||
| - One font family may not include 100% overlap with what Discord supports. | ||
| - A font that supports Unicode may not mesh with your game's aesthetics. | ||
| - Engine support is limited, especially for characters that rely on UTF surrogate pairs. | ||
|
|
||
| ## 3. Use the Discord Username as a Fallback | ||
|
|
||
| If a Display Name is not renderable at all, consider falling back to the user's [`Username`](https://discord.com/developers/docs/slayer-sdk/classdiscordpp_1_1UserHandle.html#a0eda41fe18b50bce373fb5a1b88cb411). | ||
|
|
||
| **Tradeoffs:** | ||
|
|
||
| - This can break immersion in a game if a friend had expected to rely on their Display Name from within the game. | ||
| - Some users consider their Username to be more private information and do not expect it to be shared by others (such as when someone is streaming and their friends list is visible). | ||
|
|
||
| --- | ||
|
|
||
| ## Change Log | ||
|
|
||
| | Date | Changes | | ||
| |---------------|---------------------------------| | ||
| | June 17, 2025 | special characters how-to added | | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.