string process
-
i have a string, i want to add "\u" for each 4 charachters of the string, when i write a for loop, it refuses adding \u, i have to add @\u for example: i have the strng 541236589632 i want to transfer it to \u5412\u3658\u9632 how can i do this on c# application
Thanks alot Hamody
-
i have a string, i want to add "\u" for each 4 charachters of the string, when i write a for loop, it refuses adding \u, i have to add @\u for example: i have the strng 541236589632 i want to transfer it to \u5412\u3658\u9632 how can i do this on c# application
Thanks alot Hamody
I assuming you are having problems with the escape character I would define the string that you are adding as follows:
private const string mystring = @"\u";
This tells the compiler to take the string litterally and not use the slash as an escape character.Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
I assuming you are having problems with the escape character I would define the string that you are adding as follows:
private const string mystring = @"\u";
This tells the compiler to take the string litterally and not use the slash as an escape character.Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)hello there, it doesnt solve the problem, i still have duble of "\\" string .... it didnt solve the problem how d u see???
Thanks alot Hamody
-
hello there, it doesnt solve the problem, i still have duble of "\\" string .... it didnt solve the problem how d u see???
Thanks alot Hamody
If you post your code and I will take a look at it then. Please also show input and output for your code and the desired output. I am not 100% sure what you are having a problem with otherwise.
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
If you post your code and I will take a look at it then. Please also show input and output for your code and the desired output. I am not 100% sure what you are having a problem with otherwise.
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)string ResultMessage=""; string varMessage; varMessage = MMOUTBOUND_DGV.Rows[0].Cells[2].Value.ToString(); for (int k = 0; k <= varMessage.Length - 1; k++) { ResultMessage = ResultMessage + "\u" + varMessage.Substring(k, 4); k = k + 3; } MessageBox.Show("ResultMessage ");
Thanks alot Hamody
-
string ResultMessage=""; string varMessage; varMessage = MMOUTBOUND_DGV.Rows[0].Cells[2].Value.ToString(); for (int k = 0; k <= varMessage.Length - 1; k++) { ResultMessage = ResultMessage + "\u" + varMessage.Substring(k, 4); k = k + 3; } MessageBox.Show("ResultMessage ");
Thanks alot Hamody
-
string ResultMessage=""; string varMessage; varMessage = MMOUTBOUND_DGV.Rows[0].Cells[2].Value.ToString(); for (int k = 0; k <= varMessage.Length - 1; k++) { ResultMessage = ResultMessage + "\u" + varMessage.Substring(k, 4); k = k + 3; } MessageBox.Show("ResultMessage ");
Thanks alot Hamody
OK, you have a choice when escape characters are wanted as literal in strings: you need to change + "\u" + to + @"\u" + or + "\\u" +
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
First may i sugest in the for loop
for (int k = 0; k <= varMessage.Length - 1; k=k+4)
and eliminate thek=k=3;
As suggested before your code must beResultMessage = ResultMessage + @"\u" + varMessage.Substring(k, 4);
helloz, am not using an escape characters, i want to change from the ASCII code, so for example: when i write in code: messagebox.show("\u0064"); it will show me the character 'd' on the message that appear, so i can't use '\\u' instead of using '\u' now what can i so to solve this problem :doh:
Thanks alot Hamody
-
OK, you have a choice when escape characters are wanted as literal in strings: you need to change + "\u" + to + @"\u" + or + "\\u" +
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)helloz, am not using an escape characters, i want to change from the ASCII code, so for example: when i write in code: messagebox.show("\u0064"); it will show me the character 'd' on the message that appear, so i can't use '\\u' instead of using '\u' now what can i so to solve this problem :doh:
Thanks alot Hamody
-
OK, you have a choice when escape characters are wanted as literal in strings: you need to change + "\u" + to + @"\u" + or + "\\u" +
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)helloz, am not using an escape characters, i want to change from the ASCII code, so for example: when i write in code: messagebox.show("\u0064"); it will show me the character 'd' on the message that appear, so i can't use '\\u' instead of using '\u' now what can i so to solve this problem
Thanks alot Hamody
-
helloz, am not using an escape characters, i want to change from the ASCII code, so for example: when i write in code: messagebox.show("\u0064"); it will show me the character 'd' on the message that appear, so i can't use '\\u' instead of using '\u' now what can i so to solve this problem
Thanks alot Hamody
Hey guys, i got the solution which is: private string HexAsciiConvert(string hex) { StringBuilder sb = new StringBuilder(); for (int i = 0; i <= hex.Length - 4; i += 4) { sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hex.Substring(i, 4), System.Globalization.NumberStyles.HexNumber)))); } return sb.ToString(); } enjoy and thanks to all of u :rose:
Thanks alot Hamody