Converting uft-16 to utf-8

Hi All,
I have file to IDoc Scenario.
Message Mapping is working fine for xml encoding UFT-8.
However Source file I am getting from client has xml encoding UTF-16.
because which my end-to-end mapping is failing.
Can you please suggest me something by which i can change UFT-16 to UFT-8 before i execute my mapping.
Regards,
Manisha

Hi Manisha,
In your sender file channel Specify the File Type Text.
Once  you have selected Text, specify a code page under File Encoding. The default setting is to use the system code page that is specific to the configuration of the installed operating system. The file content is converted to the UTF-8 code page before it is sent.
Following are the values you can use. I think in ur case use UTF-16.
○       US-ASCII
Seven-bit ASCII, also known as ISO646-US, or Basic Latin block of the Unicode character set
○       ISO-8859-1
ISO character set for Western European languages (Latin Alphabet No. 1), also known as ISO-LATIN-1
○       UTF-8
UTF-8 (BC-ABA)
○       UTF-16BE
16-bit Unicode character format, big-endian byte order
○       UTF-16LE
16-bit Unicode character format, little-endian byte order
○       UTF-16
UTF-16 (BC-ABA), byte order
Regards,
Deepak.

Similar Messages

  • Convert file format into UTF-8 while generating text file on FTP server

    Hi Expert,
    I have the requirement to generate text file store it in FTP server and file format should be in UTF-8.
    ABAP Development is completed but text file format generate in ANSI which not acceptable by client.For generating text file and store it on FTP server by using standard function module FTP_R3_TO_SERVER ,but in this function module there is no any parameter option like CODEPAGE for file format conversion. Is there any method or any function module to convert file format to UTF-8 and directly transfer or store it on FTP server.
    <<removed_by_moderator>>
    Thanks ,
    Edited by: Vijay Babu Dudla on Jan 28, 2009 12:48 AM

    I have come across the same issue.  Try calling the FTP_COMMAND function module to make it go into ASCII mode before your FTP the file, like this:
    data: result type table of text with header line.
    call function 'FTP_COMMAND'
        exporting
          handle        = hdl
          command       = 'ascii'
        tables
          data          = result
        exceptions
          tcpip_error   = 1
          command_error = 2
          data_error    = 3.
      call function 'FTP_R3_TO_SERVER'
        exporting
          handle         = hdl
          fname          = docid
          character_mode = 'X'
        tables
          text           = gt_your_table .

  • Dilemma converting arbitrary encoding to UTF-8

    Here's my dilemma: I recently modified our webapp to use UTF-8 encoding across the board, since data with special characters that users added to the content management backend was being displayed incorrectly in ISO-8859-1. It works great for Strings we get from the database, since it uses UTF-8. The problem now is that there are also files that consist of html chunks that get added to pages when they're rendered by the jsps. Those files aren't always UTF-8 encoded, so characters are displaying incorrectly in those parts of the page.
    The problem is that we don't know what encoding the html chunks are, some are ISO-8859-1, some are Windows-1252, etc. There are hundreds of them, and the users use all kinds of programs to generate the files, Frontpage, Dreamweaver, etc. so there's no common encoding used. I'm trying to modify the code that reads those files so it converts the text to UTF-8 for display, but without knowing what encoding the file is in, how can you do the conversion properly? Here's the code I have currently:
            ByteArrayInputStream contentInput = file.getContent();
            // wrap byte stream in UTF-8 character stream
            BufferedReader br = new BufferedReader(new InputStreamReader(contentInput, "UTF-8"));
            StringBuffer outputBuffer = new StringBuffer("");
            do {
                readString = br.readLine();
                outputBuffer.append(readString);
            while (readString != null);We get a ByteArrayInputStream from the third party API, which I wrap in a UTF-8 encoded BufferedReader. The problem is that, for instance, this character '�', when encoded in the file as ISO-8859-1, get's garbled when converted to UTF-8.
    My question is: Is there a way to convert text to UTF-8 without knowing the encoding of the file? I suspect the answer is no, but I'm really hoping it's yes, since the alternative is re-encoding hundreds to thousands of files in the db, then retraining hundreds of users to always save files as UTF-8. (You can't see my brain spasming at the thought of that, but trust me, it is ;P).

    As an update, in case anyone else runs into this same problem:
    I used the SmartEncodingInputStream from uncle_alice's link, and it works just well enough to solve my problem. The only encoding that it guessed correctly was UTF-8. But it guessed windows-1252 for US-ASCII, windows-1252, and ISO-8859-1. Since 1252 is a superset of ascii and 8859, using 1252 decodes all the characters correctly from those encodings. All the content I tested with was decoded correctly, presumably because it all uses one of those four encodings. The one snag I hit was that the SmartEncodingInputStream doesn't reset the InputStream after it reads it, so I have to do it manually after getting the guessed encoding. Here's the code I used:
            // Get the file content
            ByteArrayInputStream contentInput = file.getContent();
            StringBuffer outputBuffer = new StringBuffer("");
            // wrapper around the input stream that guesses the encoding of the stream
            SmartEncodingInputStream smartIS = null;   
            // use a 8k buffer, and a default encoding of windows-1252
            smartIS = new SmartEncodingInputStream(contentInput, SmartEncodingInputStream.BUFFER_LENGTH_8KB,
                    Charset.forName("windows-1252"));
            String charsetName = smartIS.getEncoding().name();      // get the name of the encoding guessed
            contentInput.reset();       // reset the position to the beginning of the stream
            byte[] contentBuffer = new byte[8192];
            int bytesRead = 0;
            while( (bytesRead = contentInput.read(contentBuffer, 0, 8192)) > 0 ) {
                // encode the output with the encoding guessed by the SmartEncodingInputStream
                outputBuffer.append(new String(contentBuffer, 0, bytesRead, charsetName));
            contentInput.close();I left out the try/catch blocks for readability. I get the ByteArrayInputStream from a library call, and end up with the file contents encoded in UTF-8 in outputBuffer.

  • Convert ASCII HttpServletRequest to UTF-8 Correctly (Possible)?

    Hi All, Is it possible to convert a request encoded in ASCII that contained UTF-8 Characters to UTF-8 correctly? I am using ATG Dynamo's Application server and for the life of me, it doesn't seem to let me encode the request in anything but ASCII. Anyone have any suggestions.
    Thanks,
    Rick

    i mean how do i get utf-8 "\ue0d0" from parsing in the string "U+e0d0"?The String object written in the form of "\u0000" has no relation with UTF-8 by itself, but the form is the Unicode escape sequence. The encoding UTF-8 is a way of transforming the String object to a byte array in a specified manner.
    If you have "U+0000" then you can replace 'U' and '+' with '\' and 'u' with a simple code, though the converted form does not work in a program. What should be done depends on what your aim is.

  • Convert Chinese signs to UTF-8

    Hi there
    I am trying to find a tool, or some code, who can help me covert Chinese signs to UTF-8 format.
    The resen is that I am working on a project who has to develop a web-site containg both english and chinese text.
    So first of all to test oure setup we need some chinese signs in UTF-8 format. Later on we will develop a work.flow that will convert those files/chinese signs.
    But right now it will be a greate help to get som input on how to get this working.
    Purhaps someone has made a smalle code who take a string af chinese signs as input and create a string of UTF-8 as output??
    Regards
    Tolstrup

    To read the file:Reader in = new InputStreamReader(
      new FileInputStream(yourChineseFile), "yourChineseFile'sEncoding"));I don't know what encoding your file is in, but it's your file not mine.
    To write the data in UTF-8:Writer out = new OutputStreamWriter(new FileOutputStream(yourUTF8File), "UTF-8");

  • Converting Chinese Characters from UTF-8 to GB2312

    Hi,
    I need to interact with an external system that only accepts GB2312 encoded strings as input.
    I have a site that is used to capture user input before feeding the data to the system. (Refer to the following)
    <%
    String strName = request.getParameter("strName");
    boolean serviceStatus = false;
    if (request.getParameter("strName") != null)
    serviceStatus=invokeTheService(strName,"text_process");
    %>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    How can i encode the "strName" variable value to "GB2312". (Do be informed that i am unable to change the meta Content-Type to GB2312)
    I had tried using the following but was unable get it right.
    strName = new String(strName.getBytes("UTF-8"),"GB2312");
    I had also tried using the CharsetEncoder.encode to attempt to encode it to GB2312 but kept getting a UnmappableCharacterException message.
    *Correct me if i'm wrong, but UTF-8 tends to represent characters in 1,2 or 3 bytes.
    In the case of chinese characters, each character is represented by 3 bytes.
    GB2312 tends to represent each character in 2 bytes.
    So if i have a 3 chinese character as input, the original strName.length() would return 9. whereas the Gb2312 encoded strName should return 6 ?

    KeithTan wrote:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    How can i encode the "strName" variable value to "GB2312". (Do be informed that i am unable to change the meta Content-Type to GB2312)Then what is the point of converting to GB2312 if you inform the recipient that it is encoded as something other than GB2312?
    >
    I had tried using the following but was unable get it right.
    strName = new String(strName.getBytes("UTF-8"),"GB2312");That can never ever be right. Java Strings are UNICODE encoded as UTF16. They are always encoded internally as UTF16 so your code says - convert the string to UTF8 bytes and then, even though they are UTF8 bytes and not GB2312 bytes, treat them as GB2312 bytes. That will almost certainly corrupt the String
    >
    I had also tried using the CharsetEncoder.encode to attempt to encode it to GB2312 but kept getting a UnmappableCharacterException message.Even if Java does support GB2312 then it is a wast of time sending GB2312 content to a client and telling the client that it is UTF-8 .

  • Converting japanese characters to UTF-8

    Hi
    I am working on a internationalized application where we display the content from Property based Resourc Bundle. The resource bundle is in Unicode format and we use UTF-8 charset in our JSP files to display it. Till this point its working perfectly. But in our application on some JSP pages we also get data from third party Components as well. For example in on of the JSP pages we get a ArrayList of some values that we need to display on the JSP page. But the problem is that this list of values is not in Unicode format. We need to convert the values in the ArrayList to their String representations that are UTF-8 compatible. We have tried a lot many number of ways but have not been able to do so. Please specify as to what should be done.

    hi,
    if your data is in unicode format then there is no issue of storing the value in ArrayList or anything.
    please check the following things,
    1.if you r getting calue from database and store it in ArrayList..please check wheather the database is unicode supporting.
    with regards,
    kss.
    (this is the sample code,
    <%@ page contentType="text/html;charset=UTF-8" %>
    <%@ page import="java.util.Hashtable" %>
    <%@ page import="rnd.DbConnection" %>
    <%@ page import="java.sql.*" %>
    <html>
    <body>
    <%
    Hashtable h = new Hashtable();
    int count = 0;
    try {
              Connection con = DbConnection.createConnection();
              Statement stmt = con.createStatement();
              String query = "select name,password from login where lang='ja'";
              ResultSet rs = stmt.executeQuery(query);
              int row = 1,coloumn = 1;
              while(rs.next()) {
                   coloumn = 1;
                   h.put(row + "table" + coloumn,rs.getString("name"));
                   coloumn++;
                   h.put(row + "table" + coloumn,rs.getString("password"));
                   count = count + 1;
                   row++;
    }catch(SQLException e) {
         System.out.println(e.getMessage());
    %>
    <table border=3 bgcolor="wheat">
         <tr>
              <td align=left>username</td>
              <td>password</td>
         </tr>
         <%
         int tr =1, tc =1;
         for(int i = 1,j = 1;i <= count;i++) {
              tc =1;
              %>
         <tr>
         <td><%= h.get(tr + "table" + tc) %></td>
         <td><% tc++; %><%= h.get(tr + "table" + tc) %></td></tr>
         <%
                   tr++;
         %>
    </table>
    </body>
    </html>
    OUTPUT
    ++++++++
    username password
    &#31169;&#12398;&#25163;&#20803;&#12395;&#12354;&#12427; &#31169;&#12398;&#25163;
    &#31169;&#12364;&#38306;&#19982;&#12375;&#12383;&#26412;&#12420; &#31169;&#12364;&#38306;
    &#20803;&#12395;&#12354;&#12427; &#20803;&#12395;

  • How to convert a String to UTF-8?

    I get user data from a JTextField using getText() method.
    But I want to convert it into UTF-8 in order to update Ms SQL2000.
    Can anybody give me a clue how to do it?

           String a = ...
           try
               byte[] b = a.getBytes("UTF8");
           catch (Exception e)
               System.out.println("caught" + e);
               e.printStackTrace();
           }

  • Converting Latin-1 to UTF-8

    Hi all,
    I'm looking to find a way in Dreamweaver to run a
    Search/Replace function to convert all my current Latin-1 character
    set special characters to UTF-8 Unicode. For example, I'd like to
    replace all my &aacute; which gives me this symbol: á to
    &225;. This would have to work for
    á,é,í,ó,ú, among several other characters.
    As it stands right now, I just use the Search and Replace function
    in Dreamweaver to convert each character at a time (e.g. once for
    all occurances of á, then again for all characters é,
    etc...). So the question is, is there a way that I can load up all
    the characters and what I want to change them to and run it in a
    batch perhaps using a saved Search/Replace function or using the
    Command function from the Menu Bar? Currently, I've used "Search
    and Replace" by Funduc (
    http://www.searchandreplace.com/search_replace.htm)
    which allows me to save all my queries and then run it as one
    batch. I was wondering if there was a way to do this in Dreamweaver
    by itself. This would be to replace all occurances of these letters
    on an old site that has a large number of pages.
    Thanks a bunch.
    Thank you all!
    alfred.

    Hi all,
    I'm looking to find a way in Dreamweaver to run a
    Search/Replace function to convert all my current Latin-1 character
    set special characters to UTF-8 Unicode. For example, I'd like to
    replace all my &aacute; which gives me this symbol: á to
    &225;. This would have to work for
    á,é,í,ó,ú, among several other characters.
    As it stands right now, I just use the Search and Replace function
    in Dreamweaver to convert each character at a time (e.g. once for
    all occurances of á, then again for all characters é,
    etc...). So the question is, is there a way that I can load up all
    the characters and what I want to change them to and run it in a
    batch perhaps using a saved Search/Replace function or using the
    Command function from the Menu Bar? Currently, I've used "Search
    and Replace" by Funduc (
    http://www.searchandreplace.com/search_replace.htm)
    which allows me to save all my queries and then run it as one
    batch. I was wondering if there was a way to do this in Dreamweaver
    by itself. This would be to replace all occurances of these letters
    on an old site that has a large number of pages.
    Thanks a bunch.
    Thank you all!
    alfred.

  • How to read / convert UTF-16 file

    Does anyone have a piece of code to read a unicode UTF-16 file and convert it (either to UTF-8 or non unicode), possible using CL_ABAP_CONV_IN_CE
    Thankx
    Norbert

    outdated now - and never answered as you can see....

  • Convert String from UTF-8 to IsoLatin1

    Hi everyone !
    I'm trying to convert a String from utf-8 to IsoLatin1, but i got somt problems.... I'm using
    actually this code, but it won't work...
    I'm getting a utf-8 html String with some data and i will write it down in latin1 to a text file
    String newString = new String(oldString.getBytes("UTF-8"), "ISO-8859-1");If i'm now writing this newString to a TextFile it contains cryptic signs like
    & # 1 3 ; or & # 1 3 7 ; or & # 1 2 8 ;(i separated this chars)
    can anyone tell me where is my fault and how can i solve this problem ?
    Thanks a lot
    Edited by: Sephiknight on Feb 23, 2008 2:41 AM

    Yes its XML, i got a web editor where i can add input (utf-8) and i want to write it down in my class to a xml file (isoLatin1).
    My code looks likte this
         public static void setEditFragment(String content, String xPath) throws Exception {
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder  = factory.newDocumentBuilder();
             Document document = builder.parse("3001300.xml");
             XPath xpath = XPathFactory.newInstance().newXPath();
             Node node = (Node)xpath.evaluate(xPath, document, XPathConstants.NODE);
            Charset charset = Charset.forName("ISO-8859-1");
            CharsetEncoder encoder = charset.newEncoder();    
            ByteBuffer buf = encoder.encode(CharBuffer.wrap(content));
            node.setTextContent(buf.toString()); 
               // Use a XSLT transformer for writing the new XML file
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
             DOMSource        source = new DOMSource( document );
             FileOutputStream os     = new FileOutputStream("tmp.xml");
             StreamResult     result = new StreamResult( os );
             transformer.transform( source, result ); 
         }The example from http://www.exampledepot.com/egs/java.nio.charset/ConvertChar.html looks great, but if I add my own input string i get a exception that looks like this
    java.nio.charset.UnmappableCharacterException: Input length = 1
         at java.nio.charset.CoderResult.throwException(Unknown Source)
         at java.nio.charset.CharsetEncoder.encode(Unknown Source)
         at HagerAbs.setEditFragment(HagerAbs.java:91)
         at HagerAbs.main(HagerAbs.java:108)When i write my input to the xml file it doesnt look like xml at all, it looks more like
    <synthese>& # 13;
    & # 13;
    & lt;br/& gt;& # 13;
    & lt;img class="thumb" src="http: ......{code}
    (i seperated the char so you can see)
    and this is not what i expected... how can i write it down correctly ?
    Edited by: Sephiknight on Feb 23, 2008 3:26 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Convertion of byte array in UTF-8 to GSM character set.

    I want to convert byte array in UTF-8 to GSM character set. Please advice How can I do that?

    String s = new String(byteArrayInUTF8,"utf-8");This will convert your byte array to a Java UNICODE UTF-16 encoded String on the assumption that the byte array represents characters encoded as utf-8.
    I don't understand what GSM characters are so someone else will have to help you with the second part.

  • UTF-8 encoding vs ISO 8859-1 encoding

    The iTunes tech specs call for UTF-8 encoding of the XML feed file; a friend of mine uses feed generator software through his blog that uses ISO 8859 encoding. Is there a way to convert the latter to UTF-8 so that iTunes tags may be successfully added?
    When I tried editing his XML file, I got error messages when I submitted the file to RSS feed validator sites (such as http://feedvalidator.org/. Any help or knowledge is appreciated because I am not the least bit expert in this coding arena.

    You don't need to convert iso 8859-1 (us-ascii) to utf-8 unless you have nonstandard characters. Basically, ascii is a subset of utf-8 and for English it will serve you just fine. You can have iTunes tags in the xml file even if the file itself is encoded in iso 8859-1.
    The error you see at feedvalidator.org is most likely a warning.
    Hope this helps!
    - Andy Kim
    Potion Factory
    http://www.potionfactory.com

  • Converting Filename Encoding

    Hello, I am trying to extract a .zip archive that contains CJK characters in its filenames. It was most likely created on a Windows machine.
    I tried the unzip utility and it produced invalid symbols. The same with 7za, but with slightly different ones. My LANG variable was set to en_US.UTF-8, but setting it to ja_JP.ujis seems to have no effect. I'm assuming that this means that the CJK filenames were encoded into the archive in a format other than UTF-8, and I need to convert it to UTF-8 for them to display properly.
    I know of convmv, and I used a shell script to test every possible encoding from `convmv --list` to no avail. I have the Unicode equivalents of the filenames for the most part, but in a format that's cumbersome to manually rename all of them, but with them I can verify if the conversion was successful or not.
    Observing the hex dump of ls and with positional deduction I concluded that U+4EBA (人) is represented as 0xC9 0x6C with the unzip output and 0xC2 0x90 0x6C with the 7za output. This also means it isn't impossible that I'm not dealing with the original encoding in the first place.
    So, why would two zip extractors produce different results, and are there any other leads to help me convert these filenames to UTF-8 correctly?
    Last edited by Cinolt (2011-04-14 00:26:41)

    Well. It looks like running WinRAR with ja_JP.utf8 seems to work.
    If wine can emulate it to work, it must work somehow natively in Linux. Even though I can get it to extract correctly I'd still appreciate if somebody could teach me the "proper" way to do it.

  • Reading UTF-7 XML document in Java

    I have an XML document and I want to add PrcessingInstruction to it.
    <?xml version="1.0" encoding="UTF-7" ?>
    <root_element>
    <sections>
    <section_introduction>
    <order-no>108800674</order-no>
    <order-type>219</order-type>
    <created-date>5. november 2008</created-date>
    when trying to parse it like
    File tmpFile = new File("C:\\ProvisioningEventError58412.xml");
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(false);
    Document doc = factory.newDocumentBuilder().parse(tmpFile);
    System.out.println("end");
    I get an exception on Document doc = factory.newDocumentBuilder().parse(tmpFile);
    org.xml.sax.SAXParseException: Invalid encoding name "UTF-7".
    [Fatal Error] ProvisioningEventError58412.xml:1:40: Invalid encoding name "UTF-7".
    Is it possible to set encoding on DocumentBuilder, so it can work with UTF-7 or is there any other was to parse it for adding ProcessingInstruction. Actually I want to add a CSS/XSL file for formatting the XML File.
    Edited by: aamaam on Jul 15, 2009 5:18 AM

    As you will see from [this Supported Encodings document|http://java.sun.com/javase/6/docs/technotes/guides/intl/encoding.doc.html], it's Java which doesn't support UTF-7, not just DocumentBuilder.
    So you have a couple of options. You could send the document back to whoever produced it and tell them that you can't process it the way it is. That's a legitimate thing to do because [the XML Recommendation|http://www.w3.org/TR/REC-xml/] only requires parsers to support UTF-8 and UTF-16. Support for other encodings is optional.
    Or you could write your own subclass of InputStreamReader which converts a stream of UTF-7 bytes into a stream of chars, and use that as a Reader which you pass to the parser. Somebody may even have done that already and posted it on the web somewhere.

Maybe you are looking for

  • XI JMS Adapter encoding and codepage (MDMP) problem

    Hi I have a scenario where i convert an IDoc into a target structure and post it onto a Websphere MQ queue using JMS adapter. The SAP system which sends the idoc is a non/unicode system and i can receive data which can either danish, polish etc. With

  • Freezes after 10.6.6 upgrade

    I have been having trouble with my iMac (freezes, spinning ball, inability to shut down with keyboard, etc.) After experiencing the spinning ball with nearly every keystroke, I began thinking it had something to do with my most recent upgrade to OS 1

  • HT201274 What is the home button?

    What in the world is the home button? I cannot remember the passcode from when I updated and now I can not get into my IPad.  It says to hold down the home button so I can get back to the original factory settings. I can not even fet the icloud backu

  • Printing problem in Laser jet 5200

    We are using HP Laserjet 5200 printer. While printing we are getting black fine spots all over. Kindly lets us know the reason. We are using original cartridges only

  • I keep getting a Gray Screen at Startup on my imac

    My imac suddenly went gray while watching videos and now it keeps going gray at startup. I tried a safe start (holding the shift key at startup) but that didn't work. Any suggestions please. BTFrustration.