Click here to Skip to main content
15,886,067 members
Home / Discussions / C#
   

C#

 
GeneralRe: App Settings Confusion - Class Library Pin
Jasmine Pomelo6-Apr-09 5:44
Jasmine Pomelo6-Apr-09 5:44 
QuestionOpen word document in seprate window Pin
amit_836-Apr-09 0:40
professionalamit_836-Apr-09 0:40 
AnswerRe: Open word document in seprate window Pin
King Julien6-Apr-09 2:10
King Julien6-Apr-09 2:10 
QuestionSending sms through .Net C# Windows Application Pin
Milind Panchal6-Apr-09 0:22
Milind Panchal6-Apr-09 0:22 
AnswerRe: Sending sms through .Net C# Windows Application Pin
stancrm6-Apr-09 0:41
stancrm6-Apr-09 0:41 
AnswerRe: Sending sms through .Net C# Windows Application Pin
King Julien6-Apr-09 0:58
King Julien6-Apr-09 0:58 
AnswerRe: Sending sms through .Net C# Windows Application Pin
thowra6-Apr-09 5:50
thowra6-Apr-09 5:50 
Questionlz77 decompression in c# (some body help me please) Pin
novhard6-Apr-09 0:07
novhard6-Apr-09 0:07 
i am a students, i am transform a code about lz77 decompression in c# from JSCRIPT
this is my c# code
public class lz77DeCompression
{
private char ReferencePrefix;
private int ReferencePrefixCode;
private int ReferenceIntBase;
private int ReferenceIntFloorCode;
private int ReferenceIntCeilCode;
private int MaxStringDistance;
private int MinStringLength;
private int MaxStringLength;
private int MaxWindowLength;

public lz77DeCompression()
{
this.ReferencePrefix ='`';
this.ReferencePrefixCode = (int)this.ReferencePrefix;
this.ReferenceIntBase = 96;
this.ReferenceIntFloorCode =(int)' ';
this.ReferenceIntCeilCode = this.ReferenceIntFloorCode + this.ReferenceIntBase -1;
this.MaxStringDistance = (int)Math.Pow(this.ReferenceIntBase ,2)-1;
this.MinStringLength = 5;
this.MaxStringLength = (int)Math.Pow(this.ReferenceIntBase, 1) - 1 + this.MinStringLength;
this.MaxWindowLength = this.MaxStringDistance + this.MinStringLength;
}

private int decodeReferenceInt(string words, int width)
{
int value;
int i;
int charcode;
value = 0;

for (i = 0; i < width;i++ )
{
value *= this.ReferenceIntBase;
charcode = (int)words[i];

if ((charcode >= this.ReferenceIntFloorCode) && (charcode <= this.ReferenceIntCeilCode))
{
value += charcode - this.ReferenceIntFloorCode;
}


/* else
{
Response.Write ( "<script type=\"javascript\">alert("+ charcode+")<//script>");
}*/
}
return value;
}

private int decodeReferenceInt(char words, int width)
{
int value;
int i;
int charcode;
value = 0;

for (i = 0; i < width; i++)
{
value *= this.ReferenceIntBase;
charcode = (int)words;

if ((charcode >= this.ReferenceIntFloorCode) && (charcode <= this.ReferenceIntCeilCode))
{
value += charcode - this.ReferenceIntFloorCode;
}


/* else
{
Response.Write ( "<script type=\"javascript\">alert("+ charcode+")<//script>");
}*/
}
return value;
}

private int decodeReferenceLength(char words)
{
return decodeReferenceInt(words, 1) + this.MinStringLength;
}

public string decompress(string words)
{
string decompressed;
int pos,distance,length;
int getSubString;
char currentChar;
char nextChar;
decompressed ="";
pos = 0;
while (pos < words.Length)
{
currentChar = words[pos];
if (currentChar!=this.ReferencePrefix)
{
decompressed += currentChar;
pos++;
}
else
{
nextChar = words[pos + 1];
if (nextChar != this.ReferencePrefix)
{
distance = decodeReferenceInt(words.Substring(pos + 1, 2), 2);
length = decodeReferenceLength (words[pos+3]);
getSubString=decompressed.Length - distance - length;
decompressed += decompressed.Substring(getSubString, length);
pos += this.MinStringLength - 1;

}
else
{
decompressed += this.ReferencePrefix;
pos += 2;
}
}
}
return decompressed;
}
}
and this the JSCRIPT code
//lz77 class
ReferencePrefix = "`";
ReferencePrefixCode = ReferencePrefix.charCodeAt(0);

ReferenceIntBase = 96;
ReferenceIntFloorCode = " ".charCodeAt(0);
ReferenceIntCeilCode = ReferenceIntFloorCode + ReferenceIntBase - 1;

MaxStringDistance = Math.pow(ReferenceIntBase, 2) - 1;
MinStringLength = 5;
MaxStringLength = Math.pow(ReferenceIntBase, 1) - 1 + MinStringLength;

MaxWindowLength = MaxStringDistance + MinStringLength;

function decodeReferenceInt(data, width) {
var value = 0;
for (var i = 0; i < width; i++) {
value *= ReferenceIntBase;
var charCode = data.charCodeAt(i);
if ((charCode >= ReferenceIntFloorCode) && (charCode <= ReferenceIntCeilCode)) {
value += charCode - ReferenceIntFloorCode;
} else {
throw "Invalid char code in reference int: " + charCode;
}
}
return value;
}

function decodeReferenceLength(data) {
return decodeReferenceInt(data, 1) + MinStringLength;
}

function decompress(data) {
var decompressed = "";
var pos = 0;
while (pos < data.length) {
var currentChar = data.charAt(pos);
if (currentChar != ReferencePrefix) {
decompressed += currentChar;
pos++;
} else {
var nextChar = data.charAt(pos + 1);
if (nextChar != ReferencePrefix) {
var distance = decodeReferenceInt(data.substr(pos + 1, 2), 2);
var length = decodeReferenceLength(data.charAt(pos + 3));
decompressed += decompressed.substr(decompressed.length - distance - length, length);
pos += MinStringLength - 1;
} else {
decompressed += ReferencePrefix;
pos += 2;
}
}
}
return decompressed;
}
//end class
when i give input input in c# code
input :
I'm just a little bit caught in the middle
Life is a maze and lov` ,"r` >!I don't know where to go I can't do it alone I've tried
And I don't know why
then the output :
I'm just a little bit caught in the middle
Life is a maze and love is a rddle
I don't know where to go I can't do it alone I've tried
And I don't know why
when i input in jscript
input :
I'm just a little bit caught in the middle
Life is a maze and lov` ,"r` >!I don't know where to go I can't do it alone I've tried
And I don't know why
then the output
output:
I'm just a little bit caught in the middle
Life is a maze and love is a riddle
I don't know where to go I can't do it alone I've tried
And I don't know why

the right output is in JSCRIPT, in c# there is missing one character
but when i try differen input :
in c#
input :
I'm just a little bit caught in the middle Life is a maze and lov` ,"r` >!I don't know where to go I can't do it alone I've tried And I don't know why
output :
I'm just a little bit caught in the middle Life is a maze and love is a riddle I don't know where to go I can't do it alone I've tried And I don't know why

in JSCRIPT
input :
I'm just a little bit caught in the middle Life is a maze and lov` ,"r` >!I don't know where to go I can't do it alone I've tried And I don't know why
output :
I'm just a little bit caught in the middle Life is a maze and love is a riddle I don't know where to go I can't do it alone I've tried And I don't know why

u can see, they have same output, and the both output are right ..

i am confuse about my program, i dont know where is the error, and what is the solution ..
i hope somebody here, can help me to solve my problem with that code ..
thank you very much ..

regards
novhard.. Smile | :)
AnswerRe: lz77 decompression in c# (some body help me please) Pin
Henry Minute6-Apr-09 1:27
Henry Minute6-Apr-09 1:27 
GeneralRe: lz77 decompression in c# (some body help me please) Pin
novhard6-Apr-09 19:07
novhard6-Apr-09 19:07 
GeneralRe: lz77 decompression in c# (some body help me please) Pin
Henry Minute7-Apr-09 0:47
Henry Minute7-Apr-09 0:47 
QuestionGarbage Collection in C#. Pin
Ashwani Dhiman5-Apr-09 23:38
Ashwani Dhiman5-Apr-09 23:38 
AnswerRe: Garbage Collection in C#. Pin
CPallini5-Apr-09 23:47
mveCPallini5-Apr-09 23:47 
AnswerRe: Garbage Collection in C#. [modified] Pin
akhilonly0075-Apr-09 23:47
akhilonly0075-Apr-09 23:47 
GeneralRe: Garbage Collection in C#. Pin
Colin Angus Mackay5-Apr-09 23:50
Colin Angus Mackay5-Apr-09 23:50 
GeneralRe: Garbage Collection in C#. Pin
akhilonly0076-Apr-09 0:04
akhilonly0076-Apr-09 0:04 
GeneralRe: Garbage Collection in C#. Pin
Colin Angus Mackay6-Apr-09 0:16
Colin Angus Mackay6-Apr-09 0:16 
GeneralRe: Garbage Collection in C#. Pin
DaveyM696-Apr-09 0:16
professionalDaveyM696-Apr-09 0:16 
GeneralRe: Garbage Collection in C#. Pin
akhilonly0076-Apr-09 0:31
akhilonly0076-Apr-09 0:31 
AnswerRe: Garbage Collection in C#. Pin
Colin Angus Mackay5-Apr-09 23:48
Colin Angus Mackay5-Apr-09 23:48 
GeneralRe: Garbage Collection in C#. Pin
S. Senthil Kumar6-Apr-09 5:22
S. Senthil Kumar6-Apr-09 5:22 
AnswerMessage Removed Pin
6-Apr-09 3:35
professionalN_tro_P6-Apr-09 3:35 
GeneralRe: Garbage Collection in C#. Pin
Colin Angus Mackay6-Apr-09 5:00
Colin Angus Mackay6-Apr-09 5:00 
GeneralRe: Garbage Collection in C#. Pin
led mike6-Apr-09 5:15
led mike6-Apr-09 5:15 
GeneralRe: Garbage Collection in C#. Pin
Dan Neely6-Apr-09 9:05
Dan Neely6-Apr-09 9:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.