adorer

I have wrote this function to help me convert hexa to arabic language

but always there is runtime exeption which is ...

Input string was not in a correct format.

what is the problem

this is my function...

public string Hex2Arabic(string msg)

{

long i;

string hex;

string c;

string correct="";

hex = msg;

if (((hex.Length % 4) != 0))

{

MessageBox.Show("hexa to arabic bad length (it is not divided by 4","error");

}

while ((hex.Length > 0))

{

c = hex.Substring(0, 4);

//i = int.Parse(("&H" + c));

i = Int64.Parse("&h"+c);

correct = (correct + ((char)(i)));

hex = hex.Substring((hex.Length - (hex.Length - 4)));

}

return correct;

}

thanks in advance...



Re: Visual C# General how to convert from hex to arabic language

Mark Benningfield

Hello All.

adorer:

To convert a hexadecimal number to integer, you can use Convert.ToInt32(hexString, 16).

See this article for more information.

HTH.






Re: Visual C# General how to convert from hex to arabic language

adorer

Mark Benningfield wrote:

Hello All.

adorer:

To convert a hexadecimal number to integer, you can use Convert.ToInt32(hexString, 16).

See this article for more information.

HTH.

thanks but now the function return everything as it is ..

if the input is 1234 1234

the output is 1234 1234

what is the problem





Re: Visual C# General how to convert from hex to arabic language

Mark Benningfield

Hello All.

adorer:

Well, I don't know, because I don't know what you want your ouput to look like. If you have a hex number of 1234 1234, I would think that it would look just like that in Arabic, since those are Arabic numerals.






Re: Visual C# General how to convert from hex to arabic language

adorer

Mark Benningfield wrote:

Hello All.

adorer:

Well, I don't know, because I don't know what you want your ouput to look like. If you have a hex number of 1234 1234, I would think that it would look just like that in Arabic, since those are Arabic numerals.

YES THIS IS ARABIC LANGUAGE CONVERTOR ...

LOOK i HAVE MODEFIED THE FUNCTION AND THE OUTPUT IS DIFFERENT NOW BUT ALWAUS IT IS SOMETHING LIKE A SQUARE (YOU KNOW THESE STRANGE CHARS)

THIS IS MY MODEFIED ONE ...

public string Hex2Arabic(string msg)

{

long i;

string hex="";

string c;

string correct="";

hex = msg;

if (((hex.Length % 4) != 0))

{

MessageBox.Show("hexa to arabic bad length (it is not divided by 4","error");

}

while ((hex.Length > 0))

{

c = hex.Substring(0, 4);

i = Convert.ToInt32(c, 16);

correct =(correct+ (char)i);

hex = hex.Substring((hex.Length - (hex.Length - 4)));

}

return correct;

}





Re: Visual C# General how to convert from hex to arabic language

adorer

YES THANKS IT IS WORKING NOW



Re: Visual C# General how to convert from hex to arabic language

Mark Benningfield

Hello All.

adorer:

Well, alright. Glad to help (I guess ).