[ejabberd] How to support Chinese username?

Badlop badlop at gmail.com
Wed Oct 7 19:17:46 MSD 2009


2009/10/7 wei <tsingmei at gmail.com>:
> I use English username "alex" to register and login, everything goes well.
> When I add a Chinese username called "中文" into the Database, user "alex" can
> add him as friend. But, I can't login as user "中文". I tried UTF-8 format JID
> node as well as ANSI format, none is available,  the return stanza is
> always:
> [008:000]    <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
> [008:000]      <not-authorized/>
> [008:000]    </failure>
> [008:000] XmppLoginTask::Advance - LOGINSTATE_SASL_RUNNING
> What's the reason?
> Bunch of Thanks.

Maybe it's how you created the account: I tried with Tkabber and
ejabberdctl, both worked.
Or maybe the problem is in your client: I tried with Tkabber and worked.
You can also try other clients like Psi, Gajim and Jabbim, probably it
will work too.

Now I describe how I tested it.
I create the account 中文 using Tkabber in my test server, and logged in
correctly.
Then tested with ejabberdctl:

$ ejabberdctl registered_users localhost
badlop
中文

$ ejabberdctl connected_users
中文@localhost/HomeTka

$ ejabberdctl user_resources 中文 localhost
HomeTka

$ ejabberdctl register 中文 localhost mypass123
User 中文@localhost already registered at node ejabberd at localhost

$ ejabberdctl register 中文2 localhost mypass123
User 中文2 at localhost succesfully registered

$ ejabberdctl registered_users localhost
badlop
中文
中文2

Then I disconnect of previous account and connect in the new 中文2:
$ ejabberdctl connected_users
中文2 at localhost/Home


In ejabberd.log I got this. You can notice that the non-ASCII
characters are strangely displayed in those informative texts:

=INFO REPORT==== 7-Oct-2009::16:47:52 ===
I(<0.360.0>:ejabberd_listener:224) : (#Port<0.3826>) Accepted
connection {{127,0,0,1},45077} -> {{127,0,0,1},5222}

=INFO REPORT==== 7-Oct-2009::16:47:52 ===
I(<0.383.0>:ejabberd_c2s:703) :
({socket_state,gen_tcp,#Port<0.3826>,<0.382.0>}) Accepted
authentication for 中æ by ejabberd_auth_internal

=INFO REPORT==== 7-Oct-2009::16:47:52 ===
I(<0.383.0>:ejabberd_c2s:817) :
({socket_state,gen_tcp,#Port<0.3826>,<0.382.0>}) Opened session for
中æ@localhost/Home

=INFO REPORT==== 7-Oct-2009::16:50:53 ===
I(<0.383.0>:ejabberd_c2s:1330) :
({socket_state,gen_tcp,#Port<0.3826>,<0.382.0>}) Close session for
中æ@localhost/Home

=INFO REPORT==== 7-Oct-2009::16:51:12 ===
I(<0.360.0>:ejabberd_listener:224) : (#Port<0.3873>) Accepted
connection {{127,0,0,1},45092} -> {{127,0,0,1},5222}

=INFO REPORT==== 7-Oct-2009::16:51:12 ===
I(<0.453.0>:ejabberd_c2s:703) :
({socket_state,gen_tcp,#Port<0.3873>,<0.452.0>}) Accepted
authentication for 中æ2 by ejabberd_auth_internal

=INFO REPORT==== 7-Oct-2009::16:51:12 ===
I(<0.453.0>:ejabberd_c2s:817) :
({socket_state,gen_tcp,#Port<0.3873>,<0.452.0>}) Opened session for
中æ2 at localhost/Home


$ ejabberdctl debug
(ejabberd at localhost)1> ets:tab2list(passwd).
[{passwd,{"badlop","localhost"},"mypass111"},
 {passwd,{[228,184,173,230,150,135],"localhost"},"mypass123"},
 {passwd,{[228,184,173,230,150,135,50],"localhost"}, "mypass123"}]


I used ejabberd 2.1.0-rc1, Erlang/OTP R13B02 and Tkabber SVN.
In previous versions of those programs, maybe the text varies,
but surely you must be able to register the account and log in correctly.


---
Badlop
ProcessOne


More information about the ejabberd mailing list