PDA

View Full Version : Parsing chat messages



Lunix
02-09-2004, 01:35 AM
Hi, If any devels are listening I am posed with the challenge of parsing chat messages. Many messages come out with u044 and u043 type characters. Is this in a particular type of encoding? If so do you have any hints on libraries that I could use to parse this? Thanks!

http://members.shaw.ca/corn/il2sig2.jpg

Lunix
02-09-2004, 01:35 AM
Hi, If any devels are listening I am posed with the challenge of parsing chat messages. Many messages come out with u044 and u043 type characters. Is this in a particular type of encoding? If so do you have any hints on libraries that I could use to parse this? Thanks!

http://members.shaw.ca/corn/il2sig2.jpg

Lunix
02-10-2004, 12:52 PM
*knock* *knock* Anyone home? I could really use this for fbdstats...

http://members.shaw.ca/corn/il2sig2.jpg

BaldieJr
02-11-2004, 11:03 PM
You aren't using php sockets on win32 are you?

I have the same freakin problem, and even found a little nasty thing that crashes the server when trying to str_replace those things.

Whats fbdaemon using? NORMAL_READ or BINARY_READ in perl?

<pre class="ip-ubbcode-code-pre">
______ _____
(, / ) /) /) , (, /
/---( _ // _(/ _ / __ ,""""]
+----/ ____)(_(_(/_(_(__(__(/____/__/ (__--------,' /---+
| / ( / ,' NR / |
|(_/ ..-""``"'-._ (_/ __,' 42 _/ |
+-.-"" "-..,____________/7,.--"" __]-----+

</pre>

Lunix
02-12-2004, 02:46 AM
Hi Baldie. No Im not using anything to do with php. Its goes fdb(perl) -&gt;fbdstats(perl) using SimpleTCP into a mysql database from which php draws data to be displayed on the frontpage. The real deal is that we have "Front lines live" which is X amount of the recent chat lines from the server. The weird encoding thing puts a damper on this. It would be nice to be able to parse this for proper display on the webpage.

http://members.shaw.ca/corn/il2sig2.jpg

BaldieJr
02-12-2004, 06:28 AM
Well, if you are just pulling from MySQL, you should be able to:
<pre class="ip-ubbcode-code-pre">
$cleaned_text = preg_replace("$some_pattern", " ", $mysql_data);
</pre>

Where $some_pattern is regexp, $mysql_data is the chat text, and " " is a blank space used to replace the regexp.

<pre class="ip-ubbcode-code-pre">
______ _____
(, / ) /) /) , (, /
/---( _ // _(/ _ / __ ,""""]
+----/ ____)(_(_(/_(_(__(__(/____/__/ (__--------,' /---+
| / ( / ,' NR / |
|(_/ ..-""``"'-._ (_/ __,' 42 _/ |
+-.-"" "-..,____________/7,.--"" __]-----+

</pre>

Lunix
02-12-2004, 10:05 AM
Thanks but running a perl compatible regex on the text is not what Im looking for. What I would like to do is to display on the webpage the text messages as they appear in the game. Currently this works great for UTF-8 but foreign languages come out in blocks of u04X characters. For awhile I was blanking it out with a s/u04\d//g but I would like map these to something for display in HTML.

http://members.shaw.ca/corn/il2sig2.jpg

BaldieJr
02-12-2004, 10:28 AM
I guess I just don't understand the problem.

If chat messages are stored in mysql (say, last 10), and you display those when the page is loaded, just regex that stuff out.

If you are reading it from a socket in real-time, you're in trouble. I just got it working, but for some reason I get random server crashes from regex'ing out the binary crap. From a socket_read... hellifino

<pre class="ip-ubbcode-code-pre">
______ _____
(, / ) /) /) , (, /
/---( _ // _(/ _ / __ ,""""]
+----/ ____)(_(_(/_(_(__(__(/____/__/ (__--------,' /---+
| / ( / ,' NR / |
|(_/ ..-""``"'-._ (_/ __,' 42 _/ |
+-.-"" "-..,____________/7,.--"" __]-----+

</pre>