Char Set Issue

Hi Guys,
I have an issue with reading some binary data (BLOB) from the a database. The field contains a huge string with a series of line feeds (new line indicators) in the middle. Now I retrieve the info from database and display the string on screen, but the screen shows the string displayed as one long line. I have a feeling I am not using the right character set, but I am not entirely sure what to do. The code looks like this;
if(rs != null){
                    while(rs.next()){
                          InputStream bodyOut = rs.getBinaryStream("STMT_INFO_BLOB");
                        if(bodyOut != null){
                            // Get bytes from the BLOB using a stream
                            BufferedReader br = new BufferedReader(new InputStreamReader(bodyOut));
                            String c;
                            //append the data to a string buffer
                           while((c = br.readLine()) != null){
                                infoStr.append(c);
               System.out.println(infoStr.toString());Displaying the String on screen is on the first part of my application. I want to send the string as an array of bytes to another application. However, I want to preserve the line feeds when converting to the byte array and sending it through. I would really appreciate some advice on what I need to do to achieve this.
Thank You

Aegis1888 wrote:
Ahhh, okay. thank you very much. That works fine except some of the characters in the string are displayed with a question mark (?) or other obscure mark. I'm assuming this means that I'm using the wrong encoding. Any idea on how i can find out what the correct encoding for the data should be?My first guess would be that the console is using an encoding that's not compatible with your program's output. On my Windows machine for example, text that I write to the console is encoded as cp1252 by default, but the console tries to decode it as cp437. I suggest you forget about the console; just write the text to a file in an encoding of your choice, then read the file with a good text editor (in other words, something other than Windows Notepad).
I'm a bit confused about character encodings. If I create a byte array and populate it with the value of the blob field in the database, will it preserve the data? Does is change the data in anyway? Does a byte array use any character encodings? If you read it as bytes and write it as bytes, nothing should change. Encodings only come into play when you convert the bytes to a string.
What I suppose I'm asking is does converting from one encoding to another encoding result in any data loss?If both encodings support all of the characters in your text, no data will be lost. But in the example above, if I try to write any characters that aren't in the seven-bit ASCII range, those characters will be decoded incorrectly or replaced with a default character (which usually gets rendered as a question mark).
By the way, if you haven't read [Spolsky's Unicode Primer|http://www.joelonsoftware.com/articles/Unicode.html] yet, I recommend you do so.

Similar Messages

  • Need info reg char set differences.

    Hi,
    In my database our Cognos people are using UTFA char set. And other people are using WE8ISO885981 char set.
    Is there any prob to have two character sets in the database. If yes what are those and how to rectify them.
    If there is any problem while recovering the database?.
    if we need to change everything into one charset how can we do that
    please help me in this issue.
    thx,
    Ray

    Your oracle client always converts client characters to the database character set. So if your database has some kind of UTF8 charset there should be no issue.
    If not you may need to convert your database to UTF8 if you need to keep such(UTF) characters in the database.
    So an oracle database could use two character set. One as default and one extra as national. But you have to use special column types(eg NVHARCHAR) to use the second national character set as type of a column.
    If you don't want to change your original table structures you may need to consider changing default character set to a UTF8 (e.g. AL32UTF8) charter set. So all of your previously used character set will be a superset of the new UTF8 so you can convert your original data.

  • Char set conversion to and from UTF-7

    Hi,
    I am working on Char set conversion to and from UTF-7. However I cannot find and ChatToByte classes for UTF-7 in i18n.jar . Any ideas as how to proceed further with this issue. I feel that there must be a way since UTF-7 is a pretty popular charset especially in emails.
    Thanx in advance.
    Khurram

    Hi!
    I had the same problem a couple of months ago. I didn't find any classes in the jdk distribution to do this, nor did I find any classes or package on the web that did this.
    The solution? I got a bit of C code from one of my working mates and converted it to Java. I have the code, but my company own the code. I have to check if it�s ok to share this code with you.
    BTW. If you find any package on the web that does this, pleas inform me.
    Regards
    Johan

  • Char set conversion for UTF-7

    Hi,
    I am working on Char set conversion to and from UTF-7. However I cannot find and ChatToByte classes for UTF-7 in i18n.jar . Any ideas as how to proceed further with this issue. I feel that there must be a way since UTF-7 is a pretty popular charset especially in emails.
    Thanx in advance.
    Khurram

    Hi Khurram,
    I don't know if this will help but see this thread:
    http://forums.java.sun.com/thread.jsp?forum=16&thread=25613
    regards,
    Joe

  • Images appear fine in Photoshop cs6 and cc, but print too dark, and also show too dark in Windows picture viewer. How can I correct this? Is this a Photoshop setting issue or what?

    Images appear fine in Photoshop cs6 and cc, but print too dark, and also show too dark in Windows picture viewer. How can I correct this? Is this a Photoshop setting issue or what?

    Ok, look at your files in Photoshop. What is the profile assigned to them? You can find this out by going to the Status bar at the bottom, clicking on the right-pointing triangle and choosing document Profile from the list.
    Then in Windows, go to your Control Panel > Color Management and add sRGB (if it isn't there) and select it as your default profile.
    I hope that will work.

  • How to handle all UTF-8 char set in BizTalk?

    Can any one let me know how to handle UTF-8 char set in BizTalk.
    My receive file can contain any character set like ÿÑÜÜŒöäåüÖÄÅÜ . I have to support all char set under the umbrella of UTF-8.
    But when i am trying to convert flat file data to xml its converting special character to ??????????.
    Thanks,

    That won't work because the content has been modified simply by posting it.
    Let's start form the beginning:
    No component will ever replace any character with '?', that just doesn't happen.
    Some programs will display '?' if the byte value does not fall within the current character set, UTF-x, ANSI, ANSI+Code Page, etc.
    You need to open the file with an advanced text editor such as Notepad++. 
    Please tell us exactly where you are seeing the '?'.
    The Code Page is not an encoding itself, it is a special way of interpreting ANSI, single byte char values 0-254, in a way that supports characters beyond the traditional Extended Character Set.
    You need to be absolutely sure what encoding and possibly Code Page the source app is sending.  Notepad++ is pretty good at sniffing this out or just ask the sender.  If you determine that it's really UTF-8, you must leave
    the Code Page property blank.

  • Problem displaying Japanese char set in JEditorPane

    Hi ,
    I am using JEditorPane for displaying html content. If the content is in English
    it is getting displayed properly . In case of Japanese char set like Shift-JIS only square
    boxes is displayed .
    I have tried the following
    1.Installed Japanese font and set regional and language options.
    2.set content type of JEditorPane as text/html and char set=Shift-JIS
    3.Used InputSteamReader for reading html document .While constructing passed char set also.
    4.Used SetText to set html content.
    5.verified font.properties file
    I am Using JDK 1.4.2
    No positive results.
    Kindly help me to resolve this . If it known bug please inform.
    U can connect me at [email protected]
    Thanks in Advance,
    Polu

    Hi,
    Thanks,
    I have tried the approach has mentioned above but still no positive result,
    Pls can u guide me ,so as to what might be the problem,
    Cheers,

  • Char Set with Portuguese special characters

    Hi all,
    it's kind of urgent. I need to create a new Output Device (SPAD transaction) with the device type ASCII. Until that, no problem, but I need this device type to allow printing special characters like Ç, ç, â, ä, º, ª, etc. Every special char is converted to "#" when I export the spool. I've tried to add the char sets 1153 and 1105 but it didn't work.
    Does anyone know which Char Set I should add to my device type in order to print those characters correctly?
    Thanks in advance!
    Rodrigo.

    Hi all,
    the problem was solved.
    Thanks

  • My nano Gen 6 just loses volume for no reason, one minute I hear the music the other it's gone, I have to raise the volume manually. Is it a setting issue or a defect? Thanks

    My nano 6g just loses volume for no reason, one minute I hear the music the other it's gone, I have to raise the volume manually. Is it a setting issue or a defect? Thanks

    If your ipod gets wet, it can cause the buttons to activate all by themselves. This can cause the volume to go up, down.
    If you have a headset with buttons on the wire, check there first. Try a different set of headphones and see what the result is.
    Finally, if the volume is changing a huge amount but only for certain tracks, there is an adjustment you can make on individual tracks in iTunes. Do a get info on one of the tracks doing this, then click the Options tab. Note that there is a volume adjustment slider. Make sure it is set to none.
    i

  • When some one calls the caller ID shows the name twice as we'll as when I receive texts it shows up twice.  I'm sure it's a simple setting issue. Any thoughts ???

    When some one calls the caller ID shows the name twice as we'll as when I receive texts it shows up twice.  I'm sure it's a simple setting issue. Any thoughts ???

    have the same issue on my 9630 after upgrading to 624 version. It momentarily shows the previously callers information before showing the new caller's info.

  • Channel in non-standard location & char set

    Hi folks,
    I have two problems. I'm useing Portal Server 3, and have a custom channel which I would like to display in the location of the small logo (in the �banner�).
    I have no idea hoe to do this, I presume I could put it there by defining a [tag:myCustomChannel], but again I don�t know how/where.
    The other thing that�s giving me a hard time is that if I set a JSP to have char-set ISO2 (<%@page contentType="text/html; charset=ISO-8859-2"%>) for eastern Europe, I get an error. Can someone help me there as well?
    Thanks
         Hunor Nam

    No way to change SU's behavior. However, you could try creating an alias, ensure it has the same name, and see if SU can find it.

  • When trying to logout, I keep getting "the application safari canceled logout" even though I am not in Safari. This only recently started happening and I'm wondering if it is a setting issue or bug. Can someone tell me what to do?

    When trying to logout, I keep getting "the application safari canceled logout" even though I am not in Safari. This only recently started happening and I'm wondering if it is a setting issue or bug. Can someone tell me what to do?

    You don't have to be "in" Safari for it to cancel logout.
    You have several different Applications open, and any one of them may cancel logout if conditions are just right.
    Quit the Applications you are no longer using and your Mac will run better and faster. And it will logout instead of cancelling.

  • To check whether all chars meet ISO-8859-1 char set

    HI,
    I am Getting the Description of the Material number in a Report.
    I Need to check whether each char by char of Material description belongs to ISO-8859-1 char set.
    How to check that?
    Regards,
    Raja Senthil N

    HI,
    I am Getting the Description of the Material number in a Report.
    I Need to check whether each char by char of Material description belongs to ISO-8859-1 char set.
    How to check that?
    Regards,
    Raja Senthil N

  • Conversion char set US7ASCII - WE8ISO8859P1

    Hi,
    how can I write US7ASCII data into a 8-bit char set (= WE8ISO8859P1)?
    many thanx in advance !
    rg

    Hi uk,
    thanx for your quick response !
    But I think I didn't describe the situation clearly. The problem is that I do no want to convert the data "off-line (by export/import)", but "online". This means that one client process (NLS_LANG=US7ASCII) reads the 7-bit data and should write them into the 8-bit character set which is a different database.
    Can't you do this by a stored procedure and if so, how ?
    Regards,
    rg
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by uk ([email protected]):
    Hi
    You asked: "How can I write US7ASCII data into a 8-bit char set (= WE8ISO8859P1)? "
    The stuff is simple. But go through the steps in order and don't skip any one of them. I will strongly recommend to test the procedure in Development and UAT and test the application as well throughly before you move to production if you are planning.
    (1) Take a full export of the database.
    (2) Shutdown the database and take a full backup.
    (3) Once the backup is successfully completed, rebuild the empty database with new character set(WE8ISO8859P1). the clause for this is - character set "WE8ISO8859P1" in the create database script.
    (4) Startup the database and do a full import from step 1.
    (5) After the full import, shutdown the database and startup. The new character set will take in place.
    This is the point by point solution.
    Good Luck!
    regards
    uk<HR></BLOCKQUOTE>
    null

  • Change char set for db

    Hi,
    ,is there a way to change the char set of the database?
    i have to apply AL32UTF8 charset for installing content db. but my db has another charset.
    what can i do?
    Regards
    Ceren

    Yes you can create a datbase which supports Japenese character set.
    The CREATE DATABASE statement has the CHARACTER SET clause and the additional optional NATIONAL CHARACTER SET to declare the character set to be used as the database character set and the national character ser. If no national character set clause is present, the national character set default to AL16UTF16.
    You can use approprite NLS charcter while creating database.

Maybe you are looking for

  • Iphoto won't open after upgrade

    I upgraded iPhoto.  Now when I try to open the application, I get a message "the photo libray needs to be updated..."  The spinning circle appears for a while, indicating 'work going on.'  Then the application shuts down.  I download photos to iPhoto

  • How do I jump to the top of the email list on an iPad?

    On the iPhone I can tap the status bar to jump to the top of the list of my unified inbox. But on the iPad that doesn't work. Tapping the center or right of the status bar in iPad email does nothing, tapping on the left side near the Wi-Fi symbol rev

  • Application with many Front Panels

    Dear all, I am working on an application which has 3-4 front panels. Like, when the application starts, the "User Profile" panel is shown. From there i can move on to 2 different panels. 1 panel is for Taking data from the new user. another for takin

  • Windows Server 2008 R2 - Activate VMs?

    Hello, from my university I received a "free" copy of Windows Server 2008 R2 Datacenter. I played around with it, especially with setting up domains and all related Servers (dns, dc, dhcp, etc...) as Virtual Machines. This worked very well, but now e

  • Operation could not be completed. (com.apple.installer.pagecontroller error -1.) What does this mean

    I downloaded LR 4, installer won't open. OS X 10.5.8