Welcome everyone

Have a big problem in the end this code

This code works with one of the chat games networks
But it does not appear the Arabic letters
But appear in this form
????????????
While the characters appear as English is

How can I deal with this situation

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Threading;
using System.Text;
using System.IO;

namespace ConquerSx.PacketHandling
{
    public class Chat
    {
        public static void Handle(Main.GameClient GC, byte[] Data)
        {

            MemoryStream MS = new MemoryStream(Data);
            BinaryReader BR = new BinaryReader(MS);
            BR.ReadBytes(8);
            ushort ChatType = (ushort)BR.ReadUInt32();
            BR.ReadBytes(13);
            string From = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
            string To = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
            BR.ReadByte();
            string Message = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
            BR.Close();
            MS.Close();
            #region BadWords
            Message = Message.Replace("http:/", "****");
            Message = Message.Replace(".net", "****");
            Message = Message.Replace(".com", "****");
            Message = Message.Replace(".tk", "****");
            Message = Message.Replace("www", "****");
            Message = Message.Replace("damn", "****");
            Message = Message.Replace("fuck", "****");
            Message = Message.Replace("shit", "****");
            Message = Message.Replace("stupid", "******");
            Message = Message.Replace("wtf", "***");
            Message = Message.Replace("idiot", "*****");
            Message = Message.Replace("fucker", "******");
            #endregion
            if (ChatType == 2104 && GC.MyChar.MyShop != null)
                GC.MyChar.MyShop.Hawk = Message;
            try
            {
                if (Message[0] == '/')
                {
                    string[] Cmd = Message.Split(' ');
                    if (Cmd[0] == "/players")
                    {
                        GC.LocalMessage(2000, "Players Online: " + Game.World.H_Chars.Count);
                        string eMsg = "";
                        foreach (Game.Character C in Game.World.H_Chars.Values)
                            eMsg += C.Name + ", ";
                        if (eMsg.Length > 1)
                            eMsg = eMsg.Remove(eMsg.Length - 2, 2);
                        GC.LocalMessage(2000, eMsg);
                    }

and other lines are ok

just those

Stupid question but do you have the Arabic Language installed?

You should probably try using UTF8 instead of the ASCII encoding as ASCII cannot deal with arabic characters.

I have worked with Arabic before, I didn't do anything special.
Just worked out of the box.

You must have to install unicode fonts (try Arial Unicode MS).

Can any of you tell me how
Will be the form of new code as I have
I've had enough

Can any of you tell me how
Will be the form of new code as I have
I've had enough

Not sure what you mean. Do u have Arabic installed?
http://www.youtube.com/watch?v=nU_zAT3RHkQ
You will need the Windows Cd handy.

yes i had
but this code use to control message from
the character say what ever
to the other character
say what it is

so this code is on part from my source
handling with agame client .


>..... what can i do ????????//

I don't understand what your talking about let's break it down.

yes i had

I assume you are talking about arabic. You are saying it was installed from before right?

but this code use to control message from
the character say what ever
to the other character
say what it is

You completely lost me here, I am gonna take a wild guess that your are writing a chat software. and By character you mean User. So your problem is that when you write in arabic you get ???? Correct?

Now Do both test machines have Arabic installed?
Have You specified the Font to use? Some fonts don't like Arabic and will cry try using Arial

the teo machines have arabic installed
but this cod as i told before one part of alot of acomplete files.cs
on my project witch >>>......
contronlling an on line game "Conquer on line privet server"

Hmm

the teo machines have arabic installed

The Two machines have arabic. Right?

but this cod as i told before one part of alot of acomplete files.cs

But this is Call of Duty as I told you before. One part (of?) has complete files?

on my project witch >>>......
contronlling an on line game "Conquer on line privet server"

No clue what you mean. there is a communication gap here.

You can talk to me in Arabic, I am not arab but I picked up quite a bit from here and there, so try and go easy if do decide to do it.

i made another one
but the same problem with it
how can i do
it the right way

public static COPacket ChatMessage(uint MessageID, string From, string To, string Message, ushort Type, uint Mesh)
        {
            byte[] Packet = new byte[8 + 34 + Message.Length + From.Length + To.Length];
            COPacket P = new COPacket(Packet);
            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)0x3ec);
            P.WriteBytes(new byte[] { 0xff, 0xff, 0xff, 0x00 });
            P.WriteInt32(Type);
            P.WriteInt32(MessageID);
            P.WriteInt32(Mesh);
            P.WriteInt32(Mesh);
            P.WriteByte(4);
            P.WriteByte((byte)From.Length);
            P.WriteString(From);
            P.WriteByte((byte)To.Length);
            P.WriteString(To);
            P.Move(1);
            if (Message.Length < 255)
                P.WriteByte((byte)(Message.Length));
            else
                P.WriteByte(255);

            P.WriteString(Message, 255);
            P.Move(6);

            return P;
        }

ok ok ok but i'll make it easy to handle with

i made the two codes that make the chat on the game working

all of our work will be in them
try them how to fix

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Threading;
using System.Text;
using System.IO;

namespace ConquerSx.PacketHandling
{
    public class Chat
    {
        public static void Handle(Main.GameClient GC, byte[] Data)
        {
            MemoryStream MS = new MemoryStream(Data);
            BinaryReader BR = new BinaryReader(MS);
            BR.ReadBytes(8);
            ushort ChatType = (ushort)BR.ReadUInt32();
            BR.ReadBytes(13);
            string From = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
            string To = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
            BR.ReadByte();
            string Message = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
            BR.Close();
            MS.Close();
>
>
>>>
public static COPacket ChatMessage(uint MessageID, string From, string To, string Message, ushort Type, uint Mesh)
        {
            byte[] Packet = new byte[8 + 34 + Message.Length + From.Length + To.Length];
            COPacket P = new COPacket(Packet);
            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)0x3ec);
            P.WriteBytes(new byte[] { 0xff, 0xff, 0xff, 0x00});

            P.WriteInt32(Type);
            P.WriteInt32(MessageID);
            P.WriteInt32(Mesh);
            P.WriteInt32(Mesh);
            P.WriteByte(4);
            P.WriteByte((byte)From.Length);
            P.WriteString(From);
            P.WriteByte((byte)To.Length);
            P.WriteString(To);
            P.Move(1);

No no, you're using Encoding.ASCII Use Encoding.UTF8 Arabic letters are Unicode, not ASCII. Therefor, trying to decode/encode them with ASCII will cause problems.

but here
i have problem
look at this
the range

P.WriteBytes(new byte[] { 0xff, 0xff, 0xff, 0x00 });

What? You're asking it to write 255 255 255 0 into the packet...I don't understand what's wrong with that...

if i use UTF8 Encoding
i have to add the range of the arabic letters but
the problem is when i do this it say
cannot convert 0x600 to byt
so how can i deal with this

Unicode characters are 2 bytes long (or more) therefore, they cannot be converted to single bytes. The byte has a range of 0->255 or -128->127, 0x600 is 1536 and is out of range. You will have to send it as an int or short (Int32 or Int16)

ok i understand now but
can you show me the form of the two
codes finally after editting them

how are they will be ......?

commented: down voted me for not doing his work for him +0

I don't understand how you can't do this yourself. You've already done it in your code samples.

I'm not doing your work for you.

sorry but i mean another thing
the arabic ranage not allawed
if i use it's range but may i need to convert
to arabic

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.