C# .NET - compress query string with special characters.
Asked By rrd
10-Mar-10 01:42 AM
Hi All,
I am trying to compress the string & pass it to the next page using query string. the string can contain the special characters like [ À Á Â Ã Ä Å Æ Ç È Ê É Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ù Ú Û Ü Ý Ÿ Þ Š Œ § ¿ ¥ ß à á â ã ä ç è é ê ÿ þ š œ ¢ £ ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý ÿ þ š]
for eg. - String can be "dear œ¢£, how are you," Then the output will be "
Untitled Page
dear œ¢£, how are y"
I am using Encoding.UTF8....
can any one please let me know that why compress() not returning whole string?
or is there any other way to achive this?
Code is here
private static string Compress(string data)
{
using (MemoryStream ms = new MemoryStream())
{
using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true))
{
zip.Write(Encoding.UTF8.GetBytes(data), 0, data.Length);
}
return Convert.ToBase64String(ms.ToArray());
}
}
Sandra Jain replied to rrd
try this:
function compress(data){
var q = {}, ret = "";
data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value){
q[key] = (q[key] ? q[key] + "," : "") + value;
});
for ( var key in q )
ret = (ret ? ret + "&" : "") + key + "=" + q[key];
return ret;
}
Reference:
http://marcgrabanski.com/article/compress-query-strings-in-javascript
rrd replied to Sandra Jain
not working
also javascript will not going to work in my case
Hesham Amin replied to rrd
I think what you'll gain by compression, will be lost by encoding. base64 encoding increases the size by about 1/3.
Also note that base 64 encoding produces + and / characters, which are not allowed in query strings. You'll need to encode it again or replace these characters.
rrd replied to Hesham Amin
Hi Hesham,
I agree what you are saying
can you tell me what is exact problem or any limitation of UTF-8 or base64
can you suggest me any other solution for this because the issue is not with the character limitation or size
alot var Hi What are Master Pages in ASP.NET? or What is a Master Page? ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page. What are the 2 important parts of a master page? The following are the 2 important parts of a master page 1. The Master Page itself 2. One or more Content Pages Can Master Pages be nested? Yes, Master Pages
Page Directive? What is the purpose of page directive in aspx page? Directive Syntax Directives are instructions used to specify settings (related to how a page should render and processed) used by the page and user control compilers when they process ASP.NET Web Forms page (.aspx) and user control (.ascx) files. These are the essential part of every ASP.NET Page or Control. Directives can be located anywhere in an .aspx or .ascx file, but the values, same as any HTML tag) that are specific to that directive. Special Note: The @ Page directive can be used only in .aspx files, and the @ Control directive can be used
Remove(e.TabPage); } _cache.Add(e.TabPage); } } private void button1_Click(object sender, EventArgs e) { TabPage page = new TabPage("TabPage" + pageNumber.ToString()); AddControlsToTabPage(page); this.tabControl1.TabPages.Add(page); pageNumber++; this.tabControl1.SelectedTab = page; } private void AddControlsToTabPage(TabPage page) { page.Controls.Add(this.tab1CheckBox1); page.Controls.Add(this.tabCheckBox2 page.Controls.Add(this.tabCheckBox3); page.Controls.Add(this.tabCheckBox4); page.Controls.Add(this.tabCheckBox5); page
renders the same css differently. Very odd. Sir also some other features : in our profile page we are not able to see the symbol of answer unchecked, checked , ignored, 3* , 1 just missed that feature. Sir, now most of things are working fine as expected ! Profile page , My Post Page etc working good ! site looks great ! Sir one thing i notice . . Every posts has the asp-net / 17 / 10371909 / gridview-sorting-using-jquery.aspx Navigation menu missing in forum merit page http: / / www.eggheadcafe.com / forummerit.aspx Regards Hi Robbe, I suggest you that, if you hi. . previously there is dropdownlist in which we used to select number of posts per page . . . but in the New site it is missing. . . . hi. . . check out the belowlines 2 Replies each Answer posted Hi Robbe, After giving replay for the question and submitting the button, page is showing the top of the page. My suggestion is if the page shows the answer which we have replied wiil be better. hi. . in the below link