Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
why cann't use Asian characters as a user' name ? Is there a solution ?
longnight
New
why cann't use Asian characters to register a user name , such like "李国蛋" "张学友"or "わかった" ?
I hope my users can use Characters which their are more familiar than Latin words .
Is there a solution ?
My website is using UTF-8 database, welcome to visit: http://www.cnfood.tk
Vanilla 2 .
I hope my users can use Characters which their are more familiar than Latin words .
Is there a solution ?
My website is using UTF-8 database, welcome to visit: http://www.cnfood.tk
Vanilla 2 .
0
Comments
1)
in vanilla\library\core\functions.validation.php
Search ValidateUsername() function and change regexp pattern from
'/^([\d\w_]{3,20})?$/si'
to
'/^([一-龠]|[ぁ-ん]|[ァ-ヴー]|[ a-zA-Z0-9_\-]|[ a-zA-Z0-9_―]){3,20}?$/u'
Above pattern is for Japanese. So you should be wrote difference depending on your language.
Now, you can use non-ascii characters for username.
2)
If you change username to non-ascii characters in profile, you may encounter 404 error after save and redirect.
in vanilla\applications\dashboard\controllers\class.profilecontroller.phpSearch Edit() function and change redirect code from
$this->RedirectUrl = Url('/profile/'.Gdn_Format::Url($User->Name));
to
$this->RedirectUrl = Url('/profile/'.$User->UserID.'/'.Gdn_Format::Url($User->Name));
2010-12-16: another solution found.
applications\dashboard\models\class.usermodel.php
change
$User = $this->SQL->Where('u.Name', $Username)->Get()->FirstRow();
to
$User = $this->SQL->Where('u.Name', urldecode($Username))->Get()->FirstRow();
I edited this and found 中文用户名解决方案 - Vanilla Forums. lol
Anyway, now 404 error has gone.
3)
In default, Vanilla count letters as ascii. Thus a non-ascii character is counted 2 or 3 length in UTF-8.
That causes a problem about 20 chars max for username. You get over limit error with 10 or 7 chars non-ascii username.
Once again in vanilla\library\core\functions.validation.php
Search ValidateLength() function and change code from
$Diff = strlen($Value) - $Field->Length;
to
$Diff = mb_strlen($Value, 'utf-8') - $Field->Length;
That's it.
One thing, I am an amateur in PHP. Actually I rent PHP dictionary from library yesterday because I know nothing.
So I guess if Vanilla core developers allows only ascii for username, maybe they have the reasons. Don't trust this hack.
I'll try your method soon !
But, change from
'/^([\d\w_]{3,20})?$/si'
to
'/^([一-龠]|[ぁ-ん]|[ァ-ヴー]|[ a-zA-Z0-9_\-]|[ a-zA-Z0-9_―]){3,20}?$/u'
How about Chinese,what should I apply ? 中文.
or What's these code's name ? I'll search them to replace.
regex - PHP -Multibyte regular expression to remove all but chinese characters...please help - Stack Overflow
so, maybe...
'/^[\d\w_\x4E00-\x9FA5]{3,20}?$/u'
Sorry, I didn't test it. It's just a thought.
btw, non-ascii user name breaks @ link function in comments.
I realized just now. I think we need more help or insensitivity.
@yu_tang
both these two hack can't use asian words ......
change to
'/^([一-龠]|[ぁ-ん]|[ァ-ヴー]|[ a-zA-Z0-9_\-]|[ a-zA-Z0-9_―]){3,20}?$/u'
resules in any words(Asian and Latin ) to register fail .
change to
'/^[\d\w_\x4E00-\x9FA5]{3,20}?$/u'
This time it still can't use Asian Characters to register , but Latins word was allowed .
try this.
'/^[\d\w_\x{4E00}-\x{9FA5}]{3,20}?$/u'
http://vanillaforums.org/discussion/14112/中文用户名解决方案
'/^([\d\w_\x80-\xff]{3,20})?$/si'
this line worked. anyway ,thanks for your kind heart ,welcome to visit my forum:
http://www.cnfood.tk/
There still be some small promblems
library/core/class.format.php
$Mixed = preg_replace( '/(^|[\s,\.])@(\w{1,20})\b/i', //{3,20} '\1'.Anchor('@\2', '/profile/\\2'),
Yes, another regexp pattern there. Good luck!
alt attribute of user's head image.
modify regexp pattern or use urldecode() function will work.
our forum is http://beta.neupioneer.com invitation register only.
http://vanillaforums.org/discussion/14112/