forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 189
Fix Arabic / complex-script text input (wide WNDCLASS + BMP-aware filters) #2574
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
Open
wahidkurdo
wants to merge
3
commits into
TheSuperHackers:main
Choose a base branch
from
wahidkurdo:fix/arabic-text-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,32 +193,80 @@ Int GameWindowManager::winFontHeight( GameFont *font ) | |
| } | ||
|
|
||
| // GameWindowManager::winIsDigit ============================================== | ||
| /** You implementation of whether or not character is a digit */ | ||
| /** You implementation of whether or not character is a digit. | ||
| * | ||
| * Complex-text patch: iswdigit is locale-dependent and in the default | ||
| * C locale only accepts ASCII 0-9. To stay consistent with the widened | ||
| * winIsAlNum / winIsAscii filters we additionally accept the common | ||
| * script-specific decimal digit ranges (Arabic-Indic, Extended | ||
| * Arabic-Indic, Devanagari, Bengali, etc.) so that digit-only text | ||
| * entry widgets work for users typing native numerals. | ||
| */ | ||
| //============================================================================= | ||
| Int GameWindowManager::winIsDigit( Int c ) | ||
| { | ||
|
|
||
| return iswdigit( c ); | ||
| if ( iswdigit( c ) ) | ||
| return 1; | ||
| // Arabic-Indic digits (U+0660..U+0669) | ||
| if ( c >= 0x0660 && c <= 0x0669 ) | ||
| return 1; | ||
| // Extended Arabic-Indic digits (U+06F0..U+06F9) | ||
| if ( c >= 0x06F0 && c <= 0x06F9 ) | ||
| return 1; | ||
| // Devanagari digits (U+0966..U+096F) | ||
| if ( c >= 0x0966 && c <= 0x096F ) | ||
| return 1; | ||
| // Bengali digits (U+09E6..U+09EF) | ||
| if ( c >= 0x09E6 && c <= 0x09EF ) | ||
| return 1; | ||
| return 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add line break between return 1; and return 0; for readability |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove line before closing parenthesis |
||
| } | ||
|
|
||
| // GameWindowManager::winIsAscii ============================================== | ||
| /** You implementation of whether or not character is ascii */ | ||
| /** You implementation of whether or not character is ascii. | ||
| * | ||
| * Complex-text patch: the original implementation used iswascii, which | ||
| * only accepts code points 0..127 and thereby filtered out every | ||
| * non-Latin character (Arabic, Hebrew, Cyrillic, CJK, accented Latin, | ||
| * etc.) before it could reach the text-entry buffer. We now accept any | ||
| * printable BMP code point (>= 0x20) that is not a Unicode control | ||
| * character. This keeps legitimate ASCII/Latin behaviour intact while | ||
| * letting complex scripts through the GadgetTextEntry aSCIIOnly gate. | ||
| */ | ||
| //============================================================================= | ||
| Int GameWindowManager::winIsAscii( Int c ) | ||
| { | ||
|
|
||
| return iswascii( c ); | ||
| // Reject C0/C1 control ranges but allow everything else in the BMP. | ||
| if ( c < 0x20 ) | ||
| return 0; | ||
| if ( c >= 0x7F && c < 0xA0 ) | ||
| return 0; | ||
| return 1; | ||
|
|
||
| } | ||
|
|
||
| // GameWindowManager::winIsAlNum ============================================== | ||
| /** Your implementation of whether or not character is alpha numeric */ | ||
| /** Your implementation of whether or not character is alpha numeric. | ||
| * | ||
| * Complex-text patch: iswalnum is locale-dependent and in the default C | ||
| * locale rejects every non-ASCII letter. We additionally accept any | ||
| * printable non-control code point above 0x7F so Arabic, Hebrew, and | ||
| * other complex scripts pass the alphaNumericalOnly filter on text | ||
| * entry widgets. | ||
| */ | ||
| //============================================================================= | ||
| Int GameWindowManager::winIsAlNum( Int c ) | ||
| { | ||
|
|
||
| return iswalnum( c ); | ||
| if ( iswalnum( c ) ) | ||
| return 1; | ||
| // Accept printable non-control code points above ASCII. | ||
| if ( c >= 0xA0 ) | ||
| return 1; | ||
| return 0; | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
| } | ||
|
|
||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment block not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request a change please if you want to correct something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is your first contribution to this repository and your fairly empty profile, you may not be completely familiar with how things commonly work on github