c# - Linq Expression for DataTable to URLEncoding only Unicode characters -


need url encode each character if unicode character or range of unicode characters leave non-unicode characters alone if have asci-ii representations using linq expressions link.

also i'm trying system detect if unicode character exists first before attempting urlencode it.

     datatable dt = new datatable();      dt.tablename = "testcase1";      dt.columns.add("label");      dt.columns.add("value");      for(int i=0; i<10; i++)      {          datarow row = dt.newrow();          row["label"] = "test ®±¶ me ™.";          row["value"] = i;          dt.rows.add(row);      }       // use linq expression url encode label field     var rowstoupdate = dt.asenumerable().where(a => a.field<string>("label").length > 0);      foreach (var row in rowstoupdate)     {         row.setfield("label", uri.escapeuristring(row[0].tostring()));     }      foreach (datarow row in dt.rows)     {         console.writeline(row["label"].tostring());         console.writeline(row["value"].tostring());     } 

the main reason want if url encode entire string makes spaces plus symbols , formatting horrendous when use in asp.net label or text box.

also in asp.net i'm using httpcontext.current.server.urlencode function encode value. in console app example above i'm using uri.escapeuristring function.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -