05-17-2010 08:38 AM
I am facing a problem while passing gzipped data using GZIPInputStream,
if i am receiving character aphostrophy(') then i m getting correct data but if string contains " ` " character ex. "shawa`s"
then its do unzipp like
so any one know the character set that GZIPInputStream can not pass?
Thanks in Advance.
05-17-2010 09:16 AM
Wait, what is happening? You use GZIP to compress "shawa`s" and when you uncompress it on BlackBerry using GZIPInputStream you get "Shawâ\u0080\u0099s" is that correct?
Two thoughts occur, one is that either what you are using to compress the text is messing up/written data is getting messed up/something along those lines or #2 that the encoding is different, Windows uses Unicode, Mac OS-X: UTF8, Linux varies but is moving (or at) UTF8. BlackBerry is ISO-8859-1 which shouldn't be a problem, I took your output text and converted it to "ISO-8859-1", then to UTF8 and got "Shaw’s", it's closer to what you wanted but missing a letter.
Hopefully that helps but I can't figure out why it might be doing that.
05-18-2010 01:30 AM
thanks for reply, you mean that there are no any "Barred characters" for GZINputStream but there is some problem during zip or unzip... i wil check it.
05-18-2010 04:17 AM - edited 05-18-2010 04:19 AM
I can assure you there are no barred characters for GZIP.
However it expects to process bytes, not text. rcmaniac25's point is there is usually some conversion between bytes and text. For example UTF-8 is one conversion code that can be used to convert a String on a BlackBerry to a sequence of bytes. If you use one "text to bytes" conversion at one end and a different one at the other, you can get issues such as the one that you see. Normal characters are fine, but the special ones get converted differently. So you need to find out which conversion is being used at the other end, and make sure you use the same one at the BlackBerry end.
05-19-2010 02:17 AM
i am using the following code for streamOperation
byte b = IOUtilities.streamToBytes(inputStream);
b1 = new ByteArrayInputStream(b);
gzis = new GZIPInputStream(b1);
byte bdata = IOUtilities.streamToBytes(gzis);
data1 = new String(bdata);
is there any problem in this code?
i am using byteb to find length of bytes for Processbar.
05-19-2010 04:02 AM
The issue here is not specifically what code you use at the BlackBerry end, or the Server end. The issue is that the code at both ends matches, specifically when it converts the text data to byte data.
In this case, you are creating the String using the default code set which I understand to be ISO-8859. You need to check that the other end is using that same code set when it converts the text data to bytes, before it supplies it to GZIP for compression.
Is that clear?
Regarding this specific code, it will work as far as I can see, but I think the use of byte  b does not help your progress bar much. It will allow you distinguish between receiving the data and unpacking the data, but I would suggest that doing them in the same operation would actually result in a faster process for your users. But this is a diversion, changing this will not effect your problem with rogue characters.
05-21-2010 03:03 AM
I tried the code for String Encoding
String str=new String(byteData,"UTF-8");
but its giving me the following Error.So any other way for Encoding?
"UnsupportingEncodingException:IOException in UniversalReader#byte ToCharArray()! Transcoder:awbfAn"
05-24-2010 04:09 AM
Sorry I misread the Exception. What it is telling you is that the byte are NOT UTF-8.
What you need to do is to make sure the bytes that you receive on the BlackBerry are the same as the bytes you actually send from the server So you need to track exactly what happens to the data.
One way of doing this involves printing the raw bytes. The easiest way to print them is to convert the bytes to hexadecimal, I believe there are a number of byte array to Hex String type routines on the forum, if not on the Web.
On the Server, print off the String you are sending, and, using a bytes-to-hex routine, the bytes that this String gets converted to before it is GZIPped. On the BlackBerry, print off the bytes that you receive using a bytes-to-hex routine.
You need to print off the raw bytes. So you can't do:
String printString = new String(<bytes>);
because this converts the bytes to characters.
Once you have done that, make sure they are the same. I'm guessing that they will be. So then you need to look at the Server and understand how it converts the Text to a sequence of bytes. What mechanism it uses must be replicated on the BlackBerry.
If it is not possible to print off the bytes sent on the Server, then you are doing to have to review the documentation to understand the format of the bytes sent.
So at this time, focus your attention on understanding what the Server does with the text and what encoding it is using, rather than trying to change the BlackBerry.