Encoding conversion in Swing?

Hi,
In working with text file, there is a default encoding to convert the charset into java String. We can check it with System.getProperty("file.encoding").
How about in Swing component? Is there another default encoding to convert the text input in the JTextField to java String? I have searched a lot of forum topics but could not find the answer. Please help. Thanks.
Best Regards,
Leslie

Hi Leslie,
that's because there isn't one. Java Strings will always be in UTF-16 Unicode, period.
The thing that will change encoding is what you input into Java, be it through a text file, a database, or input into text components.
When you type into a textfield like you mention, the characters you type in will likely arrive in whatever encoding is your current OS default. Java will convert the encoding over to UTF-16 as it gets inputted.
I imagine what you'd really like to do is input international characters into a textfield, right? Search on the Input Method Framework within this forum - there should be a fair bit of literature on it. It is the Java package that allows you to input I18N data into text components.
Hope that helps!
Martin Hughes

Similar Messages

  • Character encoding conversion for marshall/unmarshall?

    Hello, Java Web Services gurus,
    I am wondering if there is an easy/plugin-able way to do character encoding conversion transparently in the process of marshall/unmarshall.
    Basically, my input/output will always be these UTF-8 XMLs. As the backend database is ISO encoded, I hope the result of unmarshall will give me ISO strings. And when it comes to marshall, the ISO strings can be transparently turned to UTF-8 XML response. Right now I'm using JAXB's annotations to parse XML into objects.
    I understand there will be chars in the input file not able to get converted, if so, I'd be be expecting an error/exception that flags the failure
    Hope I sound clear. This has been a headache for a while. Really hope someone may help out a bit. Thanks a million in advance

    [Duplicate Post|http://forums.sun.com/thread.jspa?messageID=10971554&tstart=0#10971554]

  • Speed up Adobe Media Encoder conversion time?

    Hello I started a topic that is now answered about After Effect which can't convert h.264 (MP4) without using Adobe's media encoder. That's fine with me I just want to be able to convert the video's I use the software After Effect gives you. But I started this topic over here to ask if their is a way to speed up conversion time using the media encoder. Thanks and sorry if I don't answer all the time I only reply to answers that help not comments about the same topic .

    I don't think you can create such a thing for the general populace. There are just too many variables.
    You can take a 1 minute segment and export at various settings on your computer to get such a chart, but that will apply only to you with that material.

  • Encoding conversion in Mail adapter

    Hi,
    we have a problem with the Mail adapter...
    We try to send an email out of the XI to some service providers. The outgoing data is stored in an XML structure. This structure agrees with the conventions of the Mail Package format, which is used for dynamic Mail generation. The content of this Mail Package structure is a semicolon separated string, which should be attached as a CSV-File to the outgoing email. Up to this everything works fine. We get the email with the attachement out of the system, send it to a SMTP server and transfer it to a previous defined email address.
    But when we open the attachement (with Wordpad, Excel,...) all german umlaut have been lost. The problem is, when transfering the Mail Package content into a File, this File is UTF-8 encoded.
    Can anyone give us a hint how to convert the encoding of the attached file from UTF-8 to ISO-8859-1 (Latin-1)?
    Actual we have set the following parameters on the module page:
    Work sequence
    1. localejbs/AF_Modules/MessageTransformBean      Local Enterprise Bean      XML2Plain
    2. localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean       Local Enterprise Bean      mail
    Modulconfiguration
    XML2Plain     Transform.ContentDisposition     attachment;filename="ABC.csv"
    XML2Plain     Transform.ContentType      text/plain;charset=latin-1
    XML2Plain     Transform.ContentDescription      "ABC"
    I hope we get some help...
    Regards,
    Lars

    Hi,
    Hi
    We handled the similar requirement in our project.
    To convert the target file  encoding UTF-8 to ISO-8859-1. For this i have used XSLT mapping, by changing the output encoding as shown in the code.
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:a="urn:abc.com:pi:ab:cd:FileToMail:Mail">
    <xsl:variable name="vfileName" select="/a:MT_Mail/FileName"/>
                    <xsl:output method="text" indent="yes" encoding="iso-8859-1" media-type="TYP"/>
    also set the charset value to ISO-8859-1 as shown in the XSLT mapping
                     <xsl:text>----mime-boundary
    Content-Type: text/html; charset="ISO-8859-1"
    Content-Disposition: inline
    In Adapter module, add XMLAnonymizerBean
    Link:http://help.sap.com/saphelp_nwpi71/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
    Hope this will  resolve your issue.
    Regards,
    Divya
    Edited by: Divya_10 on Jun 14, 2011 10:20 AM

  • Encoding conversion from UTF-16 to UTF-8

    Hi all
    I have a simple java String which is in UTF-16 format. I have to convert it to UTF-8 format coz my application expects UTF-8 only.
    Can any body tell me what should i do for this???
    thanks

    but isn't it true that java supports only UTF-16 strings.
    When i create the new String by using a UTF-8 byte array , what i feel is, it'll again convert it to UTF-16 data.
    Suppose i have a String s1="dd" in UTF-16 format.
    i have another one s2="ddd" in UTF-8 format
    if i perform s1+s2 operation , how will JVL come to nkow about the encoding value for both strings??how will it perform the operation??
    plz respond back and clear my doubt........

  • Japanese JIS encoding conversion in Linux

    My program reads in a japanese data from MySQL database which the data is stored in UTF-8 and convert it into EUC-JP encoding in Linux and finally write it into a Text File. However, when I open the Text File, the contents have been garbled.
    I do not have any problem when working on the "Shift_JIS" or "SJIS" in Windows, this is because both encodings are Windows/DOS specific encoding, the "EUC-JP" SHOULD be used in Linux.
    Can somebody point me in the right direction of this ?
    Thanks

    However, when I open the Text File, the contents have been garbled. How do you open it? Is it not the opening program's issue?

  • Problem with URL encoding conversion

    Hi all,
    I am working on an I18N application and in my application one component sends the request to another component and then this component fetch that requet and extract the query-parameters from the request (HTTP request).
    Now the problem is that the input to first component can be given in one of the 5 character encodings:-
    UTF-8
    Shift_JIS
    EUC_JP
    Windows-31J
    ISO-2022-JP
    I have created a test program that convert the encoded URL from one character encoding to another character encoding. It is working successfully for the above 4 encodings but for the last encoding that is "ISO-2022-JP" this fails. The test programs is: -
    import java.io.*;
    import java.util.*;
    import java.net.URLDecoder;
    import java.net.URLEncoder;
    class JPtoUTF8{
         public static void main(String[] args){
              try{
                  String shift_jis = "%82%C8%82%A4%82%8B%82%E8";          // This is Shift_JIS encoded URL
                  String iso2022jp = "%1B%24B%24J%24%26%23k%24j%1B%28B";  // This is ISO-2022-JP encoded URL
                  String utf8 = "%E3%81%AA%E3%81%86%EF%BD%8B%E3%82%8A";   // This is the result that should be obtained
                  String decodedShift_jis = URLDecoder.decode(shift_jis,"Shift_JIS");
                  String decodedIso2022jp = URLDecoder.decode(iso2022jp,"ISO-2022-JP");
                  String encodedShift_JIS = URLEncoder.encode(decodedShift_jis,"UTF-8");
                  String encodedIso2022jp = URLEncoder.encode(decodedIso2022jp,"UTF-8");
                   System.out.println("shift_jis        = "+shift_jis);
                   System.out.println("encodedShift_JIS = "+encodedShift_JIS);
                   System.out.println("iso2022jp        = "+iso2022jp);
                   System.out.println("encodedIso2022jp = "+encodedIso2022jp);
              }catch(Exception e){
                   e.printStackTrace();
    }I am using jdk5 for this application.
    Please give your valuable suggestions.
    Thanks in advance.

    Could the cause be that ISO-2022-JP is not just ISO-2022-JP:
    http://www.w3.org/TR/japanese-xml/#AEN28427904
    Maybe what you are getting is one of the flavors, while the java urldecoder uses another flavor? Or maybe the string you are getting is incorrectly encoded to being with (might have been incorrectly converted from shift-jis)?
    With the shift-in shift-out design it is a difficult encoding to deal with under the best of circumstances, so you have my sympathy.

  • Conversion to swing

    i wrote this program originally in awt, i just converted the buttons to JButtons and now my applet won't initialize, why?
    import java.math.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JApplet;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class Lab7 extends JApplet implements ActionListener
       private Container pane;
       Picture myPicture1 = new Picture (Color.blue, Color.black, Color.red);
       Picture myPicture2 = new Picture (Color.red, Color.yellow, Color.green);
       private JButton moveButton = new JButton ("Move Picture");
       private JButton sadButton = new JButton ("Sadness");
       private JButton switchButton = new JButton ("Switch Picture");
       int x = 50;
       boolean flag = true;
       public void init()
           setBackground(Color.black);
           moveButton.addActionListener(this);
           //switchButton.addActionListener(this);
           //sadButton.addActionListener(this);
           add(switchButton);
           add(moveButton);
           add(sadButton);
       public void paint(Graphics g)
       myPicture1.draw(g);
       myPicture1.setXY(300, 20);
       myPicture1.setXY(x, 20);
       myPicture1.draw(g);
       public void actionPerformed (ActionEvent ae)
           if (x > getSize().width - 175)
               /* 175 = diameter(150) + xOffset(10) + xIncrement(5)
            * + xOffsetToNotRunToEdge(10) n
            x = 0;
            else
            x += 5;
            repaint();
       class Picture {
           private Color faceColor;
           private Color eyeColor;
            private Color smileColor;
            private int x = 50;
            private int y = 30;
            public Picture (Color f, Color e, Color s)
                faceColor = f;
                eyeColor = e;
                smileColor = s;
            public void setXY(int newX, int newY)
                x = newX;  y = newY;
    public void setColors(Color faceColor,
    Color eyeColor, Color smileColor)
         this.faceColor = faceColor;
         this.eyeColor = eyeColor;
         this.smileColor = smileColor;
           public Color getFaceColor()
               return faceColor;
           public Color getEyeColor()
               return eyeColor;
               public Color getSmileColor()
                   return smileColor;
               public void draw(Graphics g)
                   g.setColor(faceColor);
                   g.fillOval(x + 10, y + 40, 150, 150);
                   g.setColor(eyeColor);
                   g.fillOval(x + 60, y + 85, 10, 10);
                   g.fillOval(x + 100, y + 85, 10, 10);
                   g.setColor(smileColor);
                   g.drawArc(x + 35, y + 75, 100, 100, 200, 140);
             class Picture2 {
             private Color topLight;
             private Color midLight;
             private Color lowLight;
             private int x = 50;
             private int y = 30;
             public Picture2 (Color f, Color e, Color s)
                topLight = f;
                midLight = e;
                lowLight = s;
            public void setXY(int newX, int newY)
                x = newX;  y = newY;
    public void setColors(Color topLight,
    Color midLight, Color lowLight)
         this.topLight = topLight;
         this.midLight = midLight;
         this.lowLight = lowLight;
           public Color gettopLight()
               return topLight;
           public Color getmidLight()
               return midLight;
               public Color getlowLight()
                   return lowLight;
               public void draw(Graphics g)
                   g.drawRect (100, 100, 50, 150);
                   g.setColor(topLight);
                   g.fillOval (100, 100, 50, 50);
                   g.setColor(midLight);
                   g.fillOval(100, 130, 50, 50);
                   g.setColor(lowLight);
                   g.fillOval(100, 160, 50, 50);
       }

    the buttons are being added to the northPanel
    import java.math.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JApplet;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class Lab7 extends JApplet implements ActionListener
       private Container pane;
       Picture myPicture1 = new Picture (Color.blue, Color.black, Color.red);
       Picture myPicture2 = new Picture (Color.red, Color.yellow, Color.green);
       private JButton moveButton, switchButton, sadButton;
       private JPanel northPanel = new JPanel();
       private JPanel southPanel = new JPanel();
       int x = 50;
       boolean flag = true;
       public void init()
           setBackground(Color.black);
           moveButton.addActionListener(this);
           //switchButton.addActionListener(this);
           //sadButton.addActionListener(this);
           northPanel.add(switchButton);
           northPanel.add(moveButton);
           northPanel.add(sadButton);
           this.getContentPane().setLayout(new BorderLayout(30,5));
           moveButton = new JButton("Move Picture");
           switchButton = new JButton("Switch Picture");
           sadButton = new JButton("Sadness");
       public void paint(Graphics g)
       myPicture1.draw(g);
       myPicture1.setXY(300, 20);
       myPicture1.setXY(x, 20);
       myPicture1.draw(g);
       public void actionPerformed (ActionEvent ae)
           if (x > getSize().width - 175)
               /* 175 = diameter(150) + xOffset(10) + xIncrement(5)
            * + xOffsetToNotRunToEdge(10) n
            x = 0;
            else
            x += 5;
            repaint();
       class Picture {
           private Color faceColor;
           private Color eyeColor;
            private Color smileColor;
            private int x = 50;
            private int y = 30;
            public Picture (Color f, Color e, Color s)
                faceColor = f;
                eyeColor = e;
                smileColor = s;
            public void setXY(int newX, int newY)
                x = newX;  y = newY;
    public void setColors(Color faceColor,
    Color eyeColor, Color smileColor)
         this.faceColor = faceColor;
         this.eyeColor = eyeColor;
         this.smileColor = smileColor;
           public Color getFaceColor()
               return faceColor;
           public Color getEyeColor()
               return eyeColor;
               public Color getSmileColor()
                   return smileColor;
               public void draw(Graphics g)
                   g.setColor(faceColor);
                   g.fillOval(x + 10, y + 40, 150, 150);
                   g.setColor(eyeColor);
                   g.fillOval(x + 60, y + 85, 10, 10);
                   g.fillOval(x + 100, y + 85, 10, 10);
                   g.setColor(smileColor);
                   g.drawArc(x + 35, y + 75, 100, 100, 200, 140);
             class Picture2 {
             private Color topLight;
             private Color midLight;
             private Color lowLight;
             private int x = 50;
             private int y = 30;
             public Picture2 (Color f, Color e, Color s)
                topLight = f;
                midLight = e;
                lowLight = s;
            public void setXY(int newX, int newY)
                x = newX;  y = newY;
    public void setColors(Color topLight,
    Color midLight, Color lowLight)
         this.topLight = topLight;
         this.midLight = midLight;
         this.lowLight = lowLight;
           public Color gettopLight()
               return topLight;
           public Color getmidLight()
               return midLight;
               public Color getlowLight()
                   return lowLight;
               public void draw(Graphics g)
                   g.drawRect (100, 100, 50, 150);
                   g.setColor(topLight);
                   g.fillOval (100, 100, 50, 50);
                   g.setColor(midLight);
                   g.fillOval(100, 130, 50, 50);
                   g.setColor(lowLight);
                   g.fillOval(100, 160, 50, 50);
       }

  • Automating Video-to-Flash Encoding/Conversions

    Hi, I hope someone can help me with this, as numerous calls
    to Adobe have gone unanswered (no callbacks).
    I need to either find a product and/or solution that will
    enable me to convert various video formats (e.g., QuickTime, MPEG,
    Windows Media, etc.) to Flash automatically as opposed to doing it
    manually via the Macromedia Flash 8 Video Encoder or other manual
    process(es).
    A good example of the functionality I need is equivalent to
    how
    YouTube works: When you upload a
    video to YouTube, some background process/service runs that takes
    that video and converts it to Flash, and this is done
    automatically--without user/manual processing. I need to have a
    solution that does something like that.
    Any suggestions/help are/is greatly appreciated.

    In my case, this is 3 physical (not partitions) SATA II HDD's, where I spread the I/O load over all three.
    C:\ OS, programs
    D:\ Projects w/ Scratch Disks
    E:\ Media and Page File (this system)
    In the particular case above, the test Project happened to be on my E:\, along with the media, and my Page File. That is not how I normally work, but decided to leave it alone, for this timing test. It is obviously not the ideal, when it comes to "spreading the load," and is not my recommended scheme. The Export was also to that same E:\, so there should have been a bit of an I/O bottleneck there.
    I also went against my normal workflow, as I did not shut down anything, including AnitVirus, spy-sweeping and pop-up blocking, plus I had 5 tabs open and active in Chrome (my browser). Again, this should have created a bit of a CPU bottleneck.
    Still, with all those things being done in a less than ideal situation, the time was pretty good. Not sure how much I could have shaved off the Export process, had I set things up in my normal fashion, and created an ideal environment.
    Sorry to not define the terms early on.
    Good luck,
    Hunt

  • Encoding conversion issue on dblink (Oracle - Postgresql)

    I have sucessfully setup a dblink from Oracle to Postgresql.
    The Postgresql database use UTF-8 encoding for all its data.
    When I try this request SELECT * FROM "table"@Postgres , I receive this error :
    ORA-00942: Table ou vue inexistante
    [Generic Connectivity Using ODBC]DRV_DescribeTable: DB_ODBC_RECORD (1093): ; ERREUR:  le caractère 0xc5a1 du codage « UTF8 » n'a pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL Code: 1)
    ORA-02063: précédant 2 lines de RECORD
    00942. 00000 -  "table or view does not exist"
    *Cause:   
    *Action:
    Erreur à la ligne 2, colonne 5How can I get rid off of this error ?

    Do you get the same problem for all tables or if you run the select as -The problem is raised only on some tables not all.
    select * from "owner"."tablename"@hsodbc ;On a failing select, adding the "owner" doesn't solve the problem.
    Are there any error sin the trace file and if so could you post them here ?I perform this query : select * from "owner"."table"@POSTGRE
    Here are the traces :
    Oracle Corporation --- MONDAY    FEB 27 2012 16:21:54.959
        Version 10.2.0.1.0
    hoagprd (2): ; hoagprd Entered.
    HOACONN.C (244): ; [Generic Connectivity Using ODBC] version: 4.6.2.0.0070
    HOACONN.C (295): ; Class version: 200
    hoagprd (2): ; hoagprd Exited with retcode = 0.
    hoainit (3): ; hoainit Entered.
    (0): ; connect string is: defTdpName=Postgre;SYNTAX=(ORACLE8_HOA,
    BASED_ON=ORACLE8, IDENTIFIER_QUOTE_CHAR="",
    CASE_SENSITIVE=CASE_SENSITIVE_QUOTE);BINDING=<navobj><binding><datasources><da-
    tasource name='Postgre' type='GENERIC_ODBC_FOR_HS'
    connect='Postgre'><driverProperties/></datasource></datasources><remoteMachines-
    /><environment><optimizer noFlattener='true'/><misc year2000Policy='-1'
    consumerApi='1' sessionBehavior='4'/><queryProcessor parserDepth='2000'
    tokenSize='1000' noInsertParameterization='true'
    noThreadedReadAhead='true'
    noCommandReuse='true'/><debug
    generalTrace='true'/></environment></binding></navobj>
    ORACLE GENERIC GATEWAY Log File Started at 2012-02-27T16:21:54
    hoainit (3): ; hoainit Exited with retcode = 0.
    hoalgon (7): ; hoalgon Entered. name = rec_lct.
    Created new ODBC connection (136751296)
    hoalgon (7): ; hoalgon Exited with retcode = 0.
    hoaulcp (4): ; hoaulcp Entered.
    hoaulcp (4): ; hoaulcp Exited with retcode = 0.
    hoauldt (5): ; hoauldt Entered.
    hoauldt (5): ; hoauldt Exited with retcode = 0.
    hoabegn (9): ; hoabegn Entered. formatID = 306206, hoagttln = 29, hoagttid =
    PDELTAA.286b8407.4.69.1747760, hoagtbln = 10, hoagtbid = ^D, tflag = 0, initial
    = 1
    hoabegn (9): ; hoabegn Exited with retcode = 0.
    hoadtab (26): ; hoadtab Entered. count = 1
    hoadtab (26): ; schema_name = owner, table_name = table
    odbc_owner: select * from "owner"."table"
    DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du codage « UTF8 » n'a
    pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL Code: 1)
    DRV_DescribeTable: DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du
    codage « UTF8 » n'a pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL
    Code: 1)
    nvRETURN (drv_priv.c 948): -2202
    hoadtab (26): ; hoadtab Exited with retcode = 0.
    hoapars (15): ; hoapars Entered. stmtType = 0, id = 1.
    nvOUT (qp_sqtxt.c 55): SELECT * FROM "owner"."table"
    nvRETURN (qpsynon.c 1140): -1
    odbc_owner: select * from "owner"."table"
    DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du codage « UTF8 » n'a
    pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL Code: 1)
    DRV_DescribeTable: DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du
    codage « UTF8 » n'a pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL
    Code: 1)
    nvRETURN (drv_priv.c 948): -2202
    [A00D] Failed to open table Postgre:owner.table
    nvRETURN (qpbldbtn.c 502): -2202
    nvRETURN (qpbldbtn.c 382): -2202
    nvRETURN (qp_seman.c 3153): -2202
    nvRETURN (qp_yacc.c 1930): -2202
    nvRETURN (qp_compl.c 515): -2202
    nvRETURN (qp_compl.c 232): -2202
    nvRETURN (qp_compl.c 200): -2202
    hoapars (15): ; hoapars Exited with retcode = 942.
    hoadtab (26): ; hoadtab Entered. count = 1
    hoadtab (26): ; schema_name = owner, table_name = table
    odbc_owner: select * from "owner"."table"
    DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du codage « UTF8 » n'a
    pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL Code: 1)
    DRV_DescribeTable: DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du
    codage « UTF8 » n'a pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL
    Code: 1)
    nvRETURN (drv_priv.c 948): -2202
    hoadtab (26): ; hoadtab Exited with retcode = 0.
    hoapars (15): ; hoapars Entered. stmtType = 0, id = 1.
    nvOUT (qp_sqtxt.c 55): SELECT * FROM "owner"."table"
    odbc_rec: select * from "owner"."table"
    DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du codage « UTF8 » n'a
    pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL Code: 1)
    DRV_DescribeTable: DB_ODBC_POSTGRE (1093): ; ERREUR:  le caractère 0xc5a1 du
    codage « UTF8 » n'a pas d'équivalent dans « LATIN1 » (SQL State: HY000; SQL
    Code: 1)
    nvRETURN (drv_priv.c 948): -2202
    [A00D] Failed to open table Postgre:owner.table
    nvRETURN (qpbldbtn.c 502): -2202
    nvRETURN (qpbldbtn.c 382): -2202
    nvRETURN (qp_seman.c 3153): -2202
    nvRETURN (qp_yacc.c 1930): -2202
    nvRETURN (qp_compl.c 515): -2202
    nvRETURN (qp_compl.c 232): -2202
    nvRETURN (qp_compl.c 200): -2202
    hoapars (15): ; hoapars Exited with retcode = 942.

  • [SOLVED] Character encoding conversion

    Hi, my first post here...
    I'm writing a shell script (using tcl/expect) to show mails on pop server.
    How do I convert e-mail headers containing text like this:
    Subject: =?iso-8859-1?B?ZGl2ZXJ0aW1lbnRvIHNlbnphIGZpbmUgMjQgb3JlIHN1IDI0?=
    to make it readable?
    I already tried with 'iconv' and 'recode' with no luck...
    Thanks.
    Last edited by mr.entropy (2010-11-02 16:34:39)

    These subjects have (probably unnecessarily) been encoded according to RFC 2047.
    The "B" in between the 2nd and 3rd ? indicates that it is encoded using Base64 (if there's a Q it's "Quoted-Printable" see RFC RFC 2045).
    So you're looking for a Base64 decoder.
    EDIT: and there happens to be one in coreutils. 
    man base64
    Last edited by skanky (2010-11-02 14:39:06)

  • CONVERSION FROM ANSI ENCODED FILE TO UTF-8 ENCODED FILE

    Hi All,
    I have some issues in conversion of ANSI encoded file to utf encoded file. let me tell you in detail
    I have installed the Language Support for Thai Language on My Operating System.
    now, when I open my notepad and add thai character on the file and save it as ansi encoding. it saves it perfectly and also I able to see it on opening the file again.
    This file need to be read by my application , store in database and should display thai character on jsp after fetching the data from database. Currently it is showing junk character on jsp reason being that my database (UTF8 compliant database) has junk data . it has junk data because my application is not able to read it correctly from the file.
    If I save the file with encoding as UTF 8 it works fine. but my business requirement is such that the file is system generated and by default it is encoded in ANSI format. so I need to do the conversion of encoding from ANSI to UTF8 . so Any of you can guide me on the same how to do this conversion ?
    Regards
    Gaurav Nigam

    Guessing the encoding of a text file by examining its contents is tricky at best, and should only be done as a last resort. If the file is auto-generated, I would first try reading it using the system default encoding. That's what you're doing whenever you read a file with a FileReader. If that doesn't work, try using an InputStreamReader and specifying a Thai encoding like TIS-620 or cp838 (I don't really know anything about Thai encodings; I just picked those out of a quick Google search). Once you've read the file correctly, you can write the text to a new file using an OutputStreamWriter and specifying UTF-8 as the encoding. It shouldn't really be necessary to transcode files like this, but without knowing a lot more about your situation, that's all I can suggest.
    As for native2ascii, it isn't for encoding conversions. All it does is replace each non-ASCII character with its six-character Unicode escape, so "voil&#xE1;" becomes "voil\u00e1". In other words, it avoids the problem of character encodings by converting the file's contents to a form that can be stored as ASCII. It's mainly used for converting property or resource files to a form that can be read by the Properties and ResourceBundle classes.

  • Email attachment content corrupted, Encoding Issue

    Hi all, I have problem with corrupted email attachments.
    I write JSP codes to send the html file I have created as an ATTACHMENT by using codes:
    messageBodyPart = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(tempAttachment);
    messageBodyPart.setDataHandler(new DataHandler(fds));
    messageBodyPart.setFileName(filename);
    multipart.addBodyPart(messageBodyPart);
    I can successfully send out an email with attachment, however, the attachment when received by Outlook Express, Gmail, Thunderbird are fine without any corruption, but it was corrupted when received with my Outlook 2000. It is totally corrupted and cannot be converted even I change any encodings to view it. Please find below the corrupted text for your reference:
    [email protected]& @{83;g@Z8i 1MGO 6G4B 1MGO@G ?)G` 0hH94c4g@Z0! ?9>`GR 6' A$H.GQ <:8m 9W ?y5eF\=: 9xH#8& >K7AAV=C1b 9Y6x4O4Y.
    I found many resources to help people to do encoding for the mail subject and attachment file name, but coundn't find any for the encoding of the attachment content, many authors even suggest that the email client will do the job for attachment encoding conversion. But, Outlook 2000 sucks, I need to do it explicitly in the coding, would anyone of you help me?
    Thanks a lot for your help and this is urgent, your help is highly appreciated.

    Hey, where are the experts?Maybe the JavaMail experts view the JavaMail forum!
    >
    OMG, people in this forum only know how to get stuff
    from the others and never thinking of sharing your
    knowledge with the others?This is just stupid! If nobody is "sharing your knowledge" then how can others "get stuff"?
    >
    Or there are no experts in this forum???Plenty! Many have written well thought of books on various Java topics.
    I am not an expert in JavaMail but I use JavaMail and have sent JavaMail with attachments to Outlook 2000 but I have never seen your problem. Don't you think it significant that all woks OK except on Outlook 2000! Maybe printing the raw email will help you decide what is wrong.
    P.S. Consider moving the code that sends the email out fo the JSP to a class that can be tested outside the web server. Then if you have a problem you can post more than just a fragment.

  • Character conversion and NLS_LANG

    Hi,
    The Oracle doc says that character encoding conversion for Java programs using the OCI driver is dependent on NLS_LANG. But the description of this was a bit confusing. As per the doc
    "The JDBC OCI driver transfers the data from the server to the client in the character set of the database. Depending on the value of the NLS_LANG environment variable, the driver handles character set conversions in one of two ways.
    1)If the value of NLS_LANG is not specified, or if it is set to the US7ASCII or WE8ISO8859P1 character set, then the JDBC OCI driver uses Java to convert the character set from US7ASCII or WE8ISO8859P1 directly to UCS-2.
    2)If the value of NLS_LANG is set to a non-US7ASCII or non-WE8ISO8859P1 character set, then the driver changes the value of the NLS_LANG parameter on the client to UTF-8. This happens automatically and does not require any user-intervention. OCI uses the value of NLS_LANG to convert the data from the database character set to UTF-8; the JDBC driver then converts the UTF-8 data to UCS-2. "
    Now refering to case1, assume the database character set is multibyte.Does this mean that the OCI C libraries first convert this to US7ASCII or WE8ISO8859P1 and then the Java driver does the conversion from US7ASCII or WE8ISO8859P1 directly to UCS-2. If that is the case, wouldnt information get lost during the first conversion.
    Thanks,
    Tom.

    "Now refering to case1, assume the database character set is
    multibyte.Does this mean that the OCI C libraries first convert
    this to US7ASCII or WE8ISO8859P1 and then the Java driver
    does the conversion from US7ASCII or WE8ISO8859P1 directly to
    UCS-2. If that is the case, wouldnt information get lost during
    the first conversion. "
    Yes this is true. For a multibyte database character set caution
    must be taken that the client application NLS_LANG is not
    US7ASCII or WE8ISO8859P1 or data loss can occur. An effort will
    be made to remove the NLS_LANG dependency in a future release
    because the current solution is imperfect.

  • Specifying An Encoding

    Right, while this is in my head, and I don't forget it myself... ;-)
    String myString = "blah";
    byte[] myWeirdEncodingBytes = myString.getBytes("myWeirdEncoding");myString is in UTF-16, no matter what. The encoding specified in the getBytes() method is the target encoding. So myWeirdEncodingBytes is an array of bytes stored in a weird encoding, rather than UTF-16.
    String myNewString = new String(myWeirdEncodingBytes, "myWeirdEncoding");myNewString is UTF-16 again, no matter what. The encoding specified in the constructor is the source encoding. So myWeirdEncodingBytes are still in a weird encoding. But building a new String out of them requires an encoding conversion to occur, as the String must be in UTF-16. So we need to let the constructor know which encoding to convert from.
    A Java byte can be in any encoding it likes - it's simply eight raw bits of data stored in an arbitrary order. Anything extending a Java object is stored in UTF-8, except for String, which keeps its internal characters in UTF-16 encoding.
    In short, if you pull data into Java from an external source, the encoding it sits in within Java sticks to the rules above. If it first hits Java as a byte stream (say from an InputStream), it's going to be in whatever encoding it was already in. If it first hits Java as a String (say from request.getParameter() in a servlet or JSP), it will be in UTF-16, as Java will convert its encoding immediately.
    The same holds when writing back out. If you write out a series of bytes (such as with OutputStream), the resulting output is in the encoding the bytes were in to begin with. If you're outputting a String (although this is a lot rarer), it will be in UTF-16.
    Hope that clears a few people's heads (mine included!)....
    Martin Hughes

    I think that you should also point out that random data cannot be stored in a string (easily). In general:
      byte[] inputData = <some random data>;
      String inputString = new String(data, "an encoding");
      byte[] outputData = inputString.getBytes("an encoding");
      assert(inputData.equals(outputData)); // ! FALSEeven if "an encoding" is the same in both places. Why? Because some byte (or bytes) in the input stream may not be a valid character for "an encoding". In that case, the resulting character is undefined.
    However:
      String inputString = <some random string>;
      byte[] inputData = inputString.getBytes("an encoding");
      String outputString = new String(inputData, "an encoding");
      assert(inputString.equals(outputString)); // ! TRUEis guaranteed, as long as "an encoding" supports all of the characters in inputString.
    (Someone please tell me if I'm wrong!)

Maybe you are looking for

  • Frustration with Safari

    Is anyone else totally frustrated with an inability to save or print PDFs using Safari 6.0.3?  I'm tired of opening a PDF in Safari to see if it's something I want to print, and then having to reopen the same PDF in Firefox or another browser to prin

  • Encoding problem

    We are trying to retrieve saved XML documents that contain Greek characters from our database but instead of Greek characters we get ???? in the browser (and in the XML source). The documents before sent to the browser are passed through the XML pars

  • ISE Guest Activity Report

    In accord with the user guide, ISE should be able to report what URLs a guest had visited. For this functionality to work "you must enable guest access syslogging configuration on the NAD that inspects guest traffic in your Cisco ISE network". How ca

  • Locked layers shift placement

    I've been having this issue while drawing in photoshop. Even though I have a layer either fully locked or locked position, they still shift.  I will rotate the image to work on a different angle, and when I rotate back to normal placement my line wor

  • Can we call an ODI package from another ODI package within same Project?

    hi All, Can we call an ODI package from another ODI package within same Project?