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. Text Encoding

Text Encoding

Scheduled Pinned Locked Moved C#
algorithmsquestion
3 Posts 2 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.
  • G Offline
    G Offline
    Guinness4Strength
    wrote on last edited by
    #1

    I want to convert the CR & LN characters to and from their decimal values. so I would have a text variable set to "\r" and/or "\n" and I would want to display these values to the user as "13" and/or "10". Allow the user to changes these to other decimal values and convert back to the text equivalent for searching in strings. I have the convestion from decimal to character as follows, but what about the other way around ?

    string Data = INI.GetINI("Settings","Seperator","/13/10");
    string [] Seps = Data.Split('/');
    string m_Sep=null;
    foreach(string Sep in Seps)
    {
    if(Sep.Length==0)
    continue;
    m_Sep += (char)int.Parse(Sep);
    }

    I 1 Reply Last reply
    0
    • G Guinness4Strength

      I want to convert the CR & LN characters to and from their decimal values. so I would have a text variable set to "\r" and/or "\n" and I would want to display these values to the user as "13" and/or "10". Allow the user to changes these to other decimal values and convert back to the text equivalent for searching in strings. I have the convestion from decimal to character as follows, but what about the other way around ?

      string Data = INI.GetINI("Settings","Seperator","/13/10");
      string [] Seps = Data.Split('/');
      string m_Sep=null;
      foreach(string Sep in Seps)
      {
      if(Sep.Length==0)
      continue;
      m_Sep += (char)int.Parse(Sep);
      }

      I Offline
      I Offline
      if_mel_yes_else_no
      wrote on last edited by
      #2

      Converting is easier than you think. Just use basic byte-char conversion: char one = '\r'; byte val = (byte)one; //result is a 13 char two = (char)val; //result is '\r'

      G 1 Reply Last reply
      0
      • I if_mel_yes_else_no

        Converting is easier than you think. Just use basic byte-char conversion: char one = '\r'; byte val = (byte)one; //result is a 13 char two = (char)val; //result is '\r'

        G Offline
        G Offline
        Guinness4Strength
        wrote on last edited by
        #3

        thanks much

        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