Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. string process

string process

Scheduled Pinned Locked Moved C#
csharptutorialquestion
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohammad Dabaan
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • M Mohammad Dabaan

      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

      A Offline
      A Offline
      Antony M Kancidrowski
      wrote on last edited by
      #2

      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)

      M 1 Reply Last reply
      0
      • A Antony M Kancidrowski

        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)

        M Offline
        M Offline
        Mohammad Dabaan
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • M Mohammad Dabaan

          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

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          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)

          M 1 Reply Last reply
          0
          • A Antony M Kancidrowski

            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)

            M Offline
            M Offline
            Mohammad Dabaan
            wrote on last edited by
            #5

            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

            A A 2 Replies Last reply
            0
            • M Mohammad Dabaan

              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

              A Offline
              A Offline
              aSarafian
              wrote on last edited by
              #6

              First may i sugest in the for loop for (int k = 0; k <= varMessage.Length - 1; k=k+4) and eliminate the k=k=3; As suggested before your code must be ResultMessage = ResultMessage + @"\u" + varMessage.Substring(k, 4);

              M 1 Reply Last reply
              0
              • M Mohammad Dabaan

                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

                A Offline
                A Offline
                Antony M Kancidrowski
                wrote on last edited by
                #7

                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)

                M 2 Replies Last reply
                0
                • A aSarafian

                  First may i sugest in the for loop for (int k = 0; k <= varMessage.Length - 1; k=k+4) and eliminate the k=k=3; As suggested before your code must be ResultMessage = ResultMessage + @"\u" + varMessage.Substring(k, 4);

                  M Offline
                  M Offline
                  Mohammad Dabaan
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • A Antony M Kancidrowski

                    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)

                    M Offline
                    M Offline
                    Mohammad Dabaan
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • A Antony M Kancidrowski

                      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)

                      M Offline
                      M Offline
                      Mohammad Dabaan
                      wrote on last edited by
                      #10

                      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

                      M 1 Reply Last reply
                      0
                      • M Mohammad Dabaan

                        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

                        M Offline
                        M Offline
                        Mohammad Dabaan
                        wrote on last edited by
                        #11

                        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

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups