Please help me,about enter the characters &

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Please help me,about enter the characters &

Postby biobio » 05 Jul 2009, 16:14

First of all I would like to thank the author's hard work.
However, I now have a troublesome problem.
When I enter the characters & in chat box, and then return, communications will be interrupted.
And Once I used the Chinese, not the normal chat function.Chat characters by??? Character replacement.
I beg your pardon, I am relatively poor English.
Who can help me,thank you very much! :oops:
User avatar
Lapo
Site Admin
Posts: 21077
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Jul 2009, 06:44

Hi,
could you tell me exactly which example application is giving this problem to you?
Lapo
--
gotoAndPlay()
...addicted to flash games
biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Postby biobio » 06 Jul 2009, 07:07

In this example "02_SimpleLobby".
When I connect the server to enter the hall,I enter a chat box characters '&'.
Press send button,"OnDisconnect" Function is triggered.
LoginGUI page displays.I did not set the skin parameter.
All are the default.
The same as example "SFSIslandDemo".
Your help would be very grateful.
In addition, I would like to know Chinese and Unicode characters, whether or not to support?
Thank you for your time.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 06 Jul 2009, 08:09

I see the problem too - both with unicode characters and a problem with sending &

I am on summer vacation right now (although mostly simply at home), so will take a look at it slowly over the next week or so.

In general Unity supports Chinese and unicode characters if the font you use supports it!!! The API itself should not restrict that (but has an error right now it seems).

I'll post here once I've dug into it, but as I said - dont expect a fix within days. Else my wife will kill me for not relaxing in summer vacation.

/Thomas
biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Postby biobio » 06 Jul 2009, 12:29

hi,Thank you very much for the reply.I am very grateful to your work.I wish you a happy summer vacation. :D
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 11 Jul 2009, 09:37

I'm running into some issues tracking this one down, but there is at least 1 bug in the API regarding character encoding.

In Util/Entities.cs you need to replace the top ascTab declerations with this:

Code: Select all

          ascTab.Clear();
          ascTab.Add('>', ">");
          ascTab.Add('<', "&lt;");
          ascTab.Add('&', "&amp;");
          ascTab.Add('\'', "&apos;");
          ascTab.Add('"', "&quot;");


The difference being using a char as key vs. a string. The code tried to lookup using a string with a single char in it = not the same, so the hashtable never changed character.

The issue I have now is that the 1.6.6 server throws an exception. Server 1.6.5 works fine with the above.

But no matter what - above is an error fix that is valid no matter what. Will be included in next bugfix release

Tracking down the other bugs now with utf-8 characters.

/Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 11 Jul 2009, 10:30

Just keeping you posted on progress

And I've found the problem with UTF-8 too - but not fixed it. It turns out that C# is using UTF-16 while Java is UTF-8. A few feeble attempts on my end to convert on send/receive have failed. Will try to dig through it some more - but it gives me a slight headache trying to make things work.

/T
biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Postby biobio » 12 Jul 2009, 14:36

Thanks for all your help,I have been in check the API Source code,and found the bug about class Entities hashtable.I was confused about this problem UTF8 and UTF16,Therefore, only do little tracking debugging.But I will continue to find the problem.
Thanks.
:)


Us biobio
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 12 Jul 2009, 14:51

Hi

I have personally given up on finding a solution to the problem, and will hand it over to a guy I know that might be able to dig it up.

I've tried tons of ways to encode the string send to the server end (and decode it the other way around).

Characters under 127 work fine - characters above code 127 do not.

If anyone wants to dig into it too, you should look at the WriteToSocket method in SmartFoxClient.cs. Here one can give various options to turn on/off the BOM in UTF8 encoding etc.etc.etc. - but either the characters still dont turn out right - or the server simply ignores what you send to it. Very frustrating.

Another thing to know is that C# uses little endian where Java uses big endian. So looking into doing some bitshuffling to rework the bytes send might be the key.

Any help or ideas are appreciated

/Thomas
biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Postby biobio » 12 Jul 2009, 14:53

Code: Select all

ascTab.Add(">", "&gt;");
ascTab.Add("<", "&lt;");
ascTab.Add("&", "&amp;");
ascTab.Add("'", "&apos;");//Here I am not sure
ascTab.Add("\"", "&quot;");//Comparison of your code
   
ascTabRev.Add("&gt;", ">");
ascTabRev.Add("&lt;", "<");
ascTabRev.Add("&amp;", "&");
ascTabRev.Add("&apos;", "'");
ascTabRev.Add("&quot;", "\"");

I will continue to debug.
:)




biobio
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 12 Jul 2009, 14:55

Your code will not work. Please see my code post further up.

You have to use '' instead of "" to insert char keys instead of string based keys for it to work.

Only for the ascTab though

/Thomas
biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Postby biobio » 12 Jul 2009, 15:06

I post that code is copy from API Souce code,I mean that ' charcode and \ charcode opposite.
'= &apos, \ = &quot
My English is very poor :oops:

char '' string "" I know what you mean




biobio
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 12 Jul 2009, 15:14

Ahhh - right. I understand what you mean.

The &apos; is apostrophy - the ' character
The &quot; is quote - the " character

The \ character comes solely from escaping the character after it - as you cannot write ''', but have to write '\''

I'm very sure its the code is correct as posted earlier (not as it is in the API sources)

/Thomas
biobio
Posts: 8
Joined: 05 Jul 2009, 15:52
Location: Shanghai China
Contact:

Postby biobio » 12 Jul 2009, 15:32

:) Chinese is pictographic,so I was not sensitive to letters,haha ,Thank you very much for help me.I'm very Appreciating you.
'\'' ='



biobio
User avatar
Lapo
Site Admin
Posts: 21077
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Jul 2009, 18:50

thomas:
Here one can give various options to turn on/off the BOM in UTF8 encoding etc.etc.etc. - but either the characters still dont turn out right - or the server simply ignores what you send to it. Very frustrating.

BOM should be turned off.
Maybe that's the problem. What other options have you got for UTF-8?
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 3 guests