none
Escape Codes RRS feed

  • Question


  • This is my polish text - Czy na pewno chcesz usunąć

    Now in c# or vb.net what function can I call to make it "Czy na pewno chcesz usunąć" I have whole book to escape so code targeting escaping ć or ź won't work.

    Wednesday, September 17, 2014 8:11 PM

Answers

  • It looks like you are converting characters to put into an XML file.  Here is a very simple solution

                string input = "Czy na pewno chcesz usunąć";
                string output = input.Replace("ć", "ć");


    jdweng

    Thursday, September 18, 2014 1:19 AM

All replies

  • Why would it be ć

    string mystr = "Czy na pewno chcesz usunąć";
    mystr = HttpUtility.UrlEncode(mystr, Encoding.GetEncoding(1250));

    ....

    Czy+na+pewno+chcesz+usun%b9%e6

    This will convert everything:

                
           string mystr = "Czy na pewno chcesz usunąć";
                string mynewstr = string.Empty;
                int unicodeVal;
                foreach (char c in mystr)
                {
                    unicodeVal = c;
                    mynewstr += String.Concat("&#", unicodeVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), ";");
                }
                MessageBox.Show(mynewstr);

    ...

    Czy na pewno chcesz usunąć

    • Edited by cnk_gr Wednesday, September 17, 2014 8:52 PM
    Wednesday, September 17, 2014 8:50 PM
  • It looks like you are converting characters to put into an XML file.  Here is a very simple solution

                string input = "Czy na pewno chcesz usunąć";
                string output = input.Replace("ć", "ć");


    jdweng

    Thursday, September 18, 2014 1:19 AM
  • For encoding HTML strings, use HttpUtility.HtmlEncode. If it does not change your characters, this mean that they do not have to be encoded. Why you need to encode the letters? Maybe the problem can be solved otherwise without unneeded encoding.

    Thursday, September 18, 2014 6:31 PM