Java unicode encoding

hello,
possibly this is very simple, so dont laugh. an application i'm writing displays an XML document as a JTree for editing. Within the XML document I have hardcoded Unicode IPA extensions, which show up perfectly in the JTree and JTextAreas. The problem is I dont know how to copy the original Unicode encoding into another document. I want to be able to write the original encoding (something like ʃ) to another file. As it is, it seems to be getting converted into a string and then when I copy it, the new document doesnt contain the Unicode and wont display the symbols. Thanks for any help

I have the similar problem as you.
I try to write an xml file encoded with UTF-8 to Unix Solaris. I have set locale to UTF-8 on Unix . I compile my java source under Windows machine with ant which javac is encoded in UTF-8. Database(Informix) is also set to UTF-8. I can enter special characters such as Spanish from web page and save to Database and bring it back to web page. It all displays correctly. But when i try to get the data with special characters from database and write a xml file into Unix and I use different editors such as Word, Notepad, Unix vi, UltraEditor to open this xml file, the content is all garbage. My code to write the xml file is :
StringBuffer xml = new StringBuffer();
xml.append(data from database);
FileOutputStream fw = new FileOutputStream("test.xml");
log.info("-----------System Encoding: " + System.getProperty("file.encoding") + "---------");
OutputStreamWriter writer1 = new OutputStreamWriter(fw, "UTF-8");
writer1.write(xml.toString());
writer1.close();
the log file displays System Encoding: UTF-8

Similar Messages

  • Not able to display data in different columns using Unicode encoding

    Hi,
    Iam using Unicode encoding in my Java appln to support Japanese characters while downloading CSV report. But using the Unicode encoding displays all data in the first column of Excel sheet.
    Please let me know how to display data in different columns using Unicode encoding in Excel sheet.

    Hi Venkat,
    After extracting data into DSO check the request whether active or not.
    Check data in DSO in contents.
    If is there any restrictions on info providers in Queries.
    Let us know status clearly.......
    Reg
    Pra

  • Not able to display data in separate columns using Unicode encoding

    Hi,
    Iam using Unicode encoding in my Java appln to support Japanese characters while downloading CSV report. But using the Unicode encoding displays all data in the first column of Excel sheet.
    Please let me know how to display data in different columns using Unicode encoding in Excel sheet.
    This is an urgent need. Please help me out.

    Hi,
    I have no problem with item :P15_EV_LCL this is having a value my probem here is i am using java script to display the value in different color based on the condtion case
    eg:
    select
    case
    TRUNC((
    ( (NVL(Z."AEWP",0) - NVL(Z."BEWP_Final",0) ) / DECODE(Z."BEWP_Final",0,NULL,Z."BEWP_Final") ) * 100
    ),2)
    = :P15_EV_LCL
    then
    span style="background-color:lightgreen"
    || TRUNC((
    ( (NVL(Z."AEWP",0) - NVL(Z."BEWP_Final",0) ) / DECODE(Z."BEWP_Final",0,NULL,Z."BEWP_Final") ) * 100
    ),2) || '%' || /span
    else
    span style="background-color:yellow"
    || TRUNC(
    ( (NVL(Z."AEWP",0) - NVL(Z."BEWP_Final",0) ) / DECODE(Z."BEWP_Final",0,NULL,Z."BEWP_Final") ) * 100
    ),2) || '%' || /span
    end "Effort"
    from actuals Z
    If i dont use this <Span style="Background-color:color"> i am able to generate data in excel sheet if i use this color coding i am not able to get data in spread sheet.
    Please suggest
    Thanks
    Sudhir
    Edited by: Sudhir_N on Mar 23, 2009 10:00 PM

  • Java Database Encoding Problems

    Hi,
    I'm developing java under an AIX machine connecting to a DB2/400 database. The DB2/400 database contains records which are in Thai and English characters encoding.
    My Java program will have to extract these records and write them to a text file. My problem is, when I try to write the records in Thai characters, it doesn't get encoded right. Please advise me on what to do about my code. I hope anybody can help.
    Regards,
    Edgardolito

    Do you have a proof that your Java Strings contain
    the right characters?
    I think so. It's just that it's not encodedcorrectly
    when it goes to the text file.So if you have some kind of user interface and print
    this text, it shows both Thai and English correctly?The AIX machine can read and display Thai and English characters correctly. Actually, I'm developing a console application. No nifty user interfaces. I just flatly write the records to a text file.
    What's your platform's default encoding?My platform's (AIX) default encoding is inISO8859_1.
    It's locale is in English. I am not allowed tochange
    this setting.
    What encoding do you use when creating theFileReader?
    I'm not using file reader. I just use
    resultset.getString() to get the strings from the
    database and write it to the text file using a new
    BufferedWriter(new FileWriter(File));My mistake, I actually meant FileWriter. So if you
    don't state the encoding to be used, platform
    encoding will be used (in your case: ISO Latin 1,
    which of course has no support for Thai). The
    question is, what encoding should be used, as a mix
    of both languages can only be handled by Unicode
    encoding, e.g. UTF-8 or UTF-16. You could try to use
    an OutputStreamWriter based on a FileOutputStream and
    encapsulated into the BufferedWriter -- the
    OutputStreamWriter can be created for an encoding of
    your choice.please give me a sample code on how to do this... My code goes something like this:
    BuffereWriter bw = new BufferedWriter(FileWriter(new File("out.txt")));
    StringBuffer data = new StringBuffer("");
    rs = statement.executeQuery("SELECT thaiField FROM library.table");
    while(rs.next()) {
      data.append(new String(rs.getBytes(), "Cp838"));
      bw.write(data.toString());
      bw.newLine();
      bw.flush();
    bw.close();I hope you could help. Thanks a lot!

  • How to upload Unicode encoding files from web?

    Hi everyone,
    I do not manage to upload Unicode encoding CSV files from web. Currently I use class CL_HTMLB_MANAGER to upload file from web. It works fine with ANSI encoding files, but file content is not uploaded correctly with Unicode encoding files. Especially I get innumerable characters u201C#u201D throughout the string that contains the file content (For example instead of u201CSAP CATALOG CSV 2.0u201D I get u201CÿþS#A#P# #C#A#T#A#L#O#G# #C#S#V# #2#.#0#u201D).
    I did not find in forums a solution to my issue that is why I am now asking for your help.
    How can I upload Unicode encoding files from web? Do you know another way to upload file from web that is Unicode compatible?
    Remark: I tried to upload Unicode encoding files from SAP GUI using function module GUI_UPLOAD and upload is successful.
    Here is the code that I currently used.
    DATA:     lr_event_ex     TYPE REF TO if_htmlb_data,
               fileupload      TYPE REF TO cl_htmlb_fileupload,
               lr_upload_model TYPE REF TO /ccm/cl_bsp_upload_model,
               lr_error        TYPE REF TO /ccm/cx_file_upload.
    lr_event_ex =  cl_htmlb_manager=>get_event_ex( runtime->server->request ).
    IF lr_event_ex->event_name = 'fileUpload' AND lr_event_ex->event_type = 'upload'.
      fileupload ?= lr_event_ex.
      FREE lr_event_ex.
    * get the model
      lr_upload_model ?= me->get_model( model_id = 'mupl' ).
      IF NOT fileupload->file_name IS INITIAL.
    *   upload data
        TRY.
            CALL METHOD lr_upload_model->upload_data
              EXPORTING
                iv_file_name = fileupload->file_name
              CHANGING
                cv_xcontent  = fileupload->file_content.
          CATCH /ccm/cx_file_upload INTO lr_error.
        ENDTRY.
        FREE fileupload.
      ENDIF.
    ENDIF.
    Thank you in advance for helping me.
    Best regards,
    Vanessa

    Hi There,
    Please check the details for the same.
    Link: http://helpx.adobe.com/creative-cloud/help/sync-files.html#Sync or upload files
    Troubleshoot sync:     
    Error: "Unable to sync files"
    Creative Cloud File Sync | Known issues
    Thanks,
    Atul Saini

  • Converting String to unicode encoded string

    Hi,
    I would like to convert non-ascii characters in a String or the whole string to unicode encoded character.
    For example:
    If i have some japanese character, I would like it to be converted to /uxxxx
    How can i do this? I don't want the exact character, as I am able to get that using getBytes("encoding format"). All i want is code point representation of the non ascii unicode characters.
    Any help to do this will be appreciated.
    Thanks in advance.

    I tried to do what that but I am not sure whether that is right or not.
    String inputStr = "some non ascii string";
    char[] charArray = inputStr.toCharArray();
    int code;
    StringBuffer sb = new StringBuffer();
    for(int i = 0; i < charArray.length; i++)
    code = (int) charArray;
    String hexString = Integer.toHexString( code );
    sb.append(hexString);
    System.out.println("Code point is "+sb.toString());
    My above code does not work as expected. Could you please tell me where i am goofing?
    Thanks!

  • Default Unicode encoding on SAP ERP?

    Hello there! Who could help me out and tell me where I can find official SAP information about what is the default Unicode encoding if I choose to install SAP ERP Unicode system. Is it UTF-8 or UTF-16? Installer does not ask this question, it just asks you to pick "Unicode" or "Non-Unicode". How can I find out if the database will be UTF-8 or UTF-16? Tried to find documents but could not find any. Any links to any official documentation that has the answer would be greatly appreciated!

    Hi Anand,
    Seems like you failed to complete the pre-installation steps...
    As far as i can see there a Mount access failure, meaning the shares or mounts necesary for the installation are either unavailable or the user <sap>sid don't have enough rights to use it.
    Check all your pre-intallation steps (included on the installation guide available at SAP Marketplace) and try it agian.
    regards
    Juan

  • How to Convert From HEX to Java Unicode

    String hexString = "81698a94816a93fa97a790bb8dec8f8a814083478393835e815b83768389834383598354815b836f8e968bc69594814083568358836583808c9f8fd8835a8393835e";
    I have an hex string as shown above. Could please some one tell me how to convert to java unicode.

    Divide it into four-character pieces and for each piece to this:char c = (char)Integer.parseInt(thePiece, 16);That converts the four-character piece (e.g. "8a94") to the corresponding Unicode character (\u8a94). String those chars together into a char array or a String or whatever you need.

  • Help,DataInputStream and Unicode encoding problem

    Hello,everybody
    I am writing a small software for fun,but an problem about Unicode encoding stopped me. I tried to parse a file including integers,floats and Unicode characters(not UTF-8 but some other encoding type). I looked for the JDK documentation and I found that the class DataInputStream( implementing the interface DataInput) fitted my requirement best, then I tried but the Unicode characters are not read correctly( messy codes,only '????????').
    would you please help me? thanks a lot :-)

    the class DataInputStream has the methods useful to me, but find there is no method to set the encoding format ,both in DataInputStream and argument types used in its constructor:
    FileInputStream fis=new FileInputStream(fileName);
    DataInputStream     dis=new DataInputStream(fis);
    String line =dis.readLine();               System.out.println(line);
    // only "????????" output as result :-(
    I wonder how to set the encoding type,or another class.
    if I do it this way,it works,but there is no methods such as "readFloat","readInt",etc, so it's not what I want :
    FileInputStream fis=new FileInputStream(fileName);
    InputStreamReader read=new InputStreamReader(fis,"GB2312");
    BufferedReader reader=new BufferedReader(read);
    DataInputStream     dis=new DataInputStream(fis);
    String line = reader.readLine();
    System.out.println(line);
    thank you for your repley!

  • A/V capture in java and encoding in windows media 9 format

    Hi,
    Is it possible to capture using java and encode it in windows media 9 format ? If so how would one do it ? Thanks.
    KM

    Hey, I am trying to find out how to do this as well.
    This line throws an exception:
    Player player = Manager.createRealizedPlayer( mediaURL );
    Have either of you gotten further?

  • Unicode encoding

    Hi,
    We have a Non-Unicode System,Single Code Page configuration
    TCPDB: Database code pages    
    1100   SAP internal, like ISO 8859-1        (00697/00819)
    We have the processor architecture Big Endian 4102
    Oracle DB NLS_CHARACTERSET  WE8DEC
    What Unicode encoding will be using in this scenario?
    (UTF-8/CESU-8/UTF-16/UCS-2/UCS-4)?
    Regards,
    Etsg

    You can try this:
    Quit Mail, open Terminal and type:
    defaults write com.apple.mail NSPreferredMailCharset "UTF-8"
    Normally using a macron or any diacritics beyond what are in French and German should probably change you messages to UTF-8 automatically.

  • Unicode encoding in java

    Hi all,
    I have a file which contain data in UTF-16BE format, i want to send that data to SMS, but to send data in SMS i usually have in following format
    cmpmessage="\u0645\u0639\u0632\u0632\u0635\u0627\u0631\u0641"
    Now when i copy data from file it contains some unreadable format.
    Can any one guide that how i can convert that file in \u sequences.
    Regards,
    imran

    hi,
    when i send message by this code it shows boxes on mobile
    in = new InputStreamReader(new FileInputStream(file),"UTF-16BE");
    buf_reader = new BufferedReader(in);
    line = buf_reader.readLine();
    but when i send message by following line mobile shows proper arabic
    line="\u0645\u0639\u0632\u0632\u0635\u0627\u0631\u0641";
    Regards,
    imran

  • String unicode - Encoding used ?

    Hi,
    Can some one please provide me information on how is it working?
    1) String uses unicode. Does it just stores unicode equivaluent or it
    uses any encoding for storing the unicode value. I have got various
    responses ranging from UTF-8 , UTF-16 to default encoding of the system.
    2) If it doesn't uses default encoding of the system then please let me know how the following works
    String x = "Some japanese character" // read from file using default encoding
    Runtime.exec("echo" + x "> file") ; //
    Who does the conversion from String 's encoding to platforms default encoding?
    If the string doesn't uses encoding and stores it as unicode equivaluent , then also who does the converstion from unicode equivalent to platform's local encoding

    http://java.sun.com/docs/books/tutorial/i18n/text/index.html

  • Difficulty with java Unicode for internationalization

    First, my appologies for the cross-post. I'm not sure if this is a
    configuration issue, simple java / jsp problem or something others
    performing internationalization may have encountered.
    We're generating UTF-8 HTML pages using .jsp's, Weblogic 5.1 sp5, jdk
    1.2.2 and NT 4.0 w/ the Euro patch.
    We have the ability to serve UTF-8 encoded data from flat files and our
    database but we're having some problems serving Unicode that have been
    "escaped" into java variables.
    If we use the &#nnnnn (nnnn is decimal unicode value for character) HTML
    method for displaying unicode characters, they display just fine.
    However, if we create a java String or char and push a character into it
    via \uNNNNN (NNNNN is hex unicode value for character) and then display
    the content of this variable through the HTML page, something goes
    awry. Here's an example:
    <% String checkChar = new String("\u0000");%>
    <td class="smallfont"><% checkChar = "\u00A5";%><%=checkChar%></td>
    <td class="smallfont"><% checkChar = "\u20A5";%><%=checkChar%></td>
    <td class="smallfont"><% checkChar = "\u30A5";%><%=checkChar%></td>
    This should display the Yen symbol, Mil Sign and a Katakana small 'u',
    respectively. Oddly enough, it displays the Yen symbol all three
    times. I've had similar results with other series of Unicode characters
    (several Unicode characters that share the same second hex digit.)
    If you want to see this via HTML, check out
    http://dev.slingshotcorp.com/char.jsp.
    We've added "-Dfile.encoding=UTF8" to the java invocation in
    startWebLogic.cmd and we've verified that the setting is persisted into
    the .jsp. Unfortunately, our output isn't affected.
    Anyone know what I'm doing wrong? It appears that java is somehow
    assuming the first hex digit is always "00." Does this sound familiar
    to anyone?
    Thanks - Jackson

    Hello Earl,
    I was having similar problem.
    I was able to display &#nnnnn and the chinese character
    from database, but not \unnnn.
    I think Kevin Burns was making a good suggestion by
    giving page directive in your jsp file (UTF8) 'cause that's what
    I did AND it started to display \unnnn just fine from
    my property bundle files. You may give a try!
    But my problem is that after I gave the UTF8 page directive,
    the stuff I'm reading from db (oracle 8.1.6, with NLS_LANG)
    displayed as garbage. Do you think it's because that
    WLS supports only Unicode?
    thanks,
    --Renqi Li
    Earl Bob wrote:
    Has any else come across this gem? I think this is the root of my problem.
    "Caution: Currently, WebLogic JSP only supports 8-bit character sets. "
    http://www.inf.fu-berlin.de/lehre/WS00/SWT/BEA/documentation/docs51/classdocs/API_jsp.html
    The most recent Weblogic documentation has revised this statement to:
    "WebLogic JSP supports mulitbyte character sets according to the Unicode
    standard. "
    http://www.weblogic.com/docs51/classdocs/API_jsp.html#wljsp
    We believe that the 16-bit characters we're passing around through Java
    variables are being cliped to 8-bit characters as they're written to HTML.
    Does anyone know when (which service pack) provided WL 5.1 JSP with the
    ability to handle multi-byte charactersets? We're currently using WL 5.1
    sp5.
    Thanks - Jackson

  • A java unicode problem against MySQL

    Hi members,
    need your suggestions regarding a weird problem.
    I have a standalone java utility which is used parse xmls containing english and hindi text and store the data in MySQL. I can see data stored as hindi in the MySQL database. the data is correctly stored in the database.
    All character sets and collations seem to be set correct. Character set in Mysql itable, columns and database is UTF8 and Collations are utf8_unicode_ci.
    But the problem now is that, when i try to retrieve the data from the database - the hindi text comes out as ???????.
    Any ideas would be appreciated.
    MySQL 5.0
    JDBC - 5.0
    Connection uri = String uri = "jdbc:mysql://localhost:3306/DATABASE_NAME?useUnicode=true&characterEncoding=UTF8";
    Thanks,
    VK

    Vishal.MK wrote:
    But the problem now is that, when i try to retrieve the data from the database - the hindi text comes out as ???????.I'd guess you have a problem when printing the data retrieved from the database and not with the actual retrieving.
    A "?" is generated when you try to convert some text into an encoding that doesn't support the Unicode codepoints used in the text. For example, if you try to convert 3 Unicode codepoints from the Hindi area into ISO-8859-1 (which basically supports the latin alphabet only) you'll get 3 question marks.
    How do you print that text? If you use System.out.println() and are using Windows, then you should know that the Windows command line window (used by cmd.exe and java.exe) only has very limited support for text outside the current locales code page.
    Try displaying the String using Swing (JOptionPane is probably the easiest way) or print the separate values of the characters of the String to verify that they are restored correctly.

Maybe you are looking for