I need to create an app on Asp.net/PHP [Both are welcome]
User can register with a arabic username or English username.
say that user registered with English username A ,
So when another user tried to register with Arabic version of A then i need to deny it.
How its posible ?
is there any way to get a unique value for both A ?
Thanks.
Simply manipulate unicode strings. A good choice of encoding is UTF-8, for example.
You should only manipulate unicode strings throughout your program, to avoid issues with some characters getting garbled when users enter special characters.
If what you’re seeking to do is compare strings with some characters considered equivalent, for example with english and greek, A would be equivalent to alpha, then you need to build a list of equivalences, and transform the strings into a sequence of numbers, where each number is the number of the equivalence class of the character in the original string.
The fastest method would be to build a dictionary (key/value pairs) like this, in PHP:
where you would replace
'alif'and'baa'by the actual arabic characters in unicode.Then, transform the strings:
And then compare two transformed strings.
This is called collating, and can also be used for case-insensitive comparisons of strings (make
'ab'equivalent to'AB').Other than using numbers to identify the character classes, one can choose to use a character as the representative individual of its class. Then you would do :
This would transform the string with the characters
'a''B''U'into'aba', and the string with the characters'alif','baa','alif'into'aba', so they would be considered equivalent.You can then store the converted string in your database along with the user name, to quickly check whether a given username already exists.
I know some database engines allow you to define your own collating sequences (basically the
equivarray above), but that would be the matter for another question.