Forums Register Login

Character Encoding

+Pie Number of slices to send: Send
Hi
I had problem in converting blob object (which was stored as zip) to string. since i used different encoding format while reading from the database vs encoding used by database to convert the data to blob object.

below code creates problem if i use different encoding



i fix the issue by replacing the above code with the below one



so please advice me whether it is correct approach to fix the problem in case of reading the file in different encoding . i feel there is no much difference between code, but second code fix my problem (educate me how does the second code fix the issue).


i appreciate you reply on this
Thanks
Dhoni
+Pie Number of slices to send: Send
 

dhoni Gibson wrote:I had problem in converting blob object (which was stored as zip) to string.



If the BLOB data was originally a ZIP archive, then it doesn't make sense to convert it to a string. It isn't text data so it shouldn't be treated as a string.

However it's impossible to answer your question specifically about character encoding in your code, because the fragments you posted don't show any evidence of character encodings being used. Could you perhaps show us where you think you are using a character encoding?
+Pie Number of slices to send: Send
hi paul

appreciate your apply on this.

1) i want to convert the zip data (byte) into the character later i will form the string object.

2) i was passing the encoding as jvm argument as below.

-Dfile.encoding=UTF8

hope i answered your question


Thanks
Dhoni
+Pie Number of slices to send: Send
No, you didn't answer my question.

Character encodings are only used when bytes are converted to chars, or vice versa. Your code doesn't have any such examples. And BLOBs are binary objects, so producing a BLOB from bytes doesn't involve any character encoding.
+Pie Number of slices to send: Send

i got it. i am pasting the code with the byte to char conversion code here.


Old code here




New code with byte to char conversion



once i got all the bytes.. i will convert the bytes into the text data in the new code

+Pie Number of slices to send: Send
I'm not sure if this affecting you, but Java had a problem with foreign characters in ZipEntry. Apparently, that's fixed in Java 7, but if you're using an earlier JDK, that could be causing you problems. http://bugs.sun.com/view_bug.do?bug_id=4244499
+Pie Number of slices to send: Send
Hi Greg

Thanks for your post. i read through the link and learned issue was between two different platforms while encoding characaters.my issue is bit different, I am running my application in unix environment where i had issue while reading through zip file. i happen where my zip data is persisited in db and while reading through the java code i couldnt recreate the data inside the data.

i have fixed the issue which i have mentioned in the previous post.

i want to know whether i need to use same encoding format which my database is using.

i am using oracle database which uses US7ASCII as encoding . where as my jvm uses US-ASCII.
+Pie Number of slices to send: Send
No, I don't think it matters. Blobs are binary data and therefore not encoded. You might have to match encodings between whatever produced the zip file entry names and whatever is consuming them, but I can't see how Oracle's preferred encoding would make any difference.
Yes, my master! Here is the tiny ad you asked for:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1686 times.
Similar Threads
writing 4 byte little-endian long integers
Blob formatted in XML
Parsing a BLOB XML object
Problem regarding Image save/retrieve
Error flushing the output stream in Sun One server
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:00:03.