Linebreak in a UTF-16 file

Hi experts,
I try to create a UTF-16 File in ECC 6.0.
Open dataset xxx for otuput in binary mode.
At the end of every record I set cl_abap_char_utilities=>cr_lf.
But the linebreak is not correct.
Is there anybody how can help me.
Thanks for answer
Angelika

Hi
have you tried another attribute in CL_ABAP_CHAR_UTILITIES class.
try this : CL_ABAP_CHAR_UTILITIES=>NEWLINE
Just observe the data ... it will take ## for line break. Just try your luck with newline also..
all the very best
Regards,
Sreeni

Similar Messages

  • Byte Order Mark (BOM) not found in UTF-8 file download from XI

    Hi Guys,
    Facing difficulty in downloading file from XI in UTF-8 format with byte order mark.
    Receiver File adapter has been configured to download the file in UTF-8 file format. But the byte order mark is missing. Same works well for UTF-16. Could see the byte order mark at the beginning of  file "FEFF" for UTF-16BE - Unicode big endian.
    As per SAP help, UTF-8 supposed to be the default encoding for TEXT file type.
    Configuring the Receiver File/FTP Adapter in the SAP help link.
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/frameset.htm
    Could you please advice on how to achieve BOM in UTF-8 file as it is very important for the outbound file to get loaded in our vendor system.
    Thanks.
    Best Regards
    Thiru

    Hi!<br>
    <br>
    Had the same problem. But here, we create a "CSV"-File which must have the BOM otherwise it will not be recogniced as UTF-8.
    <br>
    Therefore I've done the folowing:
    Created a simple destination-structure which represents the CSV and done the mapping with the graphical-mapper. The destination-Structure looks like:
    <br>
    (?xml version="1.0" encoding="UTF-8"?)<br>
    (ONLYLINES)<br>
         (LINE)<br>
              (ENTRY)Hello I'm line 1(/ENTRY)<br>
         (/LINE)<br>
         (LINE)<br>
              (ENTRY)and I'm line 2(/ENTRY)<br>
         (/LINE)<br>
    (/ONLYLINES)
    As you can see, the "ENTRY"-Element holds the data.<br>
    <br>
    Now I've created the folowing Java-Mapping and added that mapping within the Interface-Mapping as second step after the graphical mapping:<br>
    <br>
    ---cut---<br>
    package sfs.biz.xi.global;<br>
    <br>
    import java.io.InputStream;<br>
    import java.io.OutputStream;<br>
    import java.util.Map;<br>
    <br>
    import javax.xml.parsers.DocumentBuilder;<br>
    import javax.xml.parsers.DocumentBuilderFactory;<br>
    <br>
    import org.w3c.dom.Document;<br>
    import org.w3c.dom.Element;<br>
    import org.w3c.dom.NodeList;<br>
    <br>
    import com.sap.aii.mapping.api.StreamTransformation;<br>
    import com.sap.aii.mapping.api.StreamTransformationException;<br>
    <br>
    public class OnlyLineConvertAddingBOM implements StreamTransformation {<br>
    <br>
         public void execute(InputStream in, OutputStream out) throws StreamTransformationException {<br>
              try {<br>
                   byte BOM[] = new byte[3];<br>
                   BOM[0]=(byte)0xEF;<br>
                   BOM[1]=(byte)0xBB;<br>
                   BOM[2]=(byte)0xBF;<br>
                   String retString=new String(BOM,"UTF-8");<br>
                   Element ServerElement;<br>
                   NodeList Server;<br>
                   <br>
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();<br>
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();<br>
                Document doc = docBuilder.parse(in);<br>
                doc.getDocumentElement().normalize();<br>
                NodeList ConnectionList = doc.getElementsByTagName("ENTRY");<br>
                int count=ConnectionList.getLength();<br>
                for (int i=0;i<count;i++) {<br>
                    ServerElement = (Element)ConnectionList.item(i);<br>
                    Server = ServerElement.getChildNodes();<br>
                    retString += Server.item(0).getNodeValue().trim() + "\r\n";<br>
                }<br>
                <br>
                out.write(retString.getBytes("UTF-8"));<br>
                   <br>
              } catch (Throwable t) {<br>
                   throw new StreamTransformationException(t.toString());<br>
              }<br>
         }<br>
    <br>
         public void setParameter(Map arg0) {<br>
              // TODO Auto-generated method stub<br>
              <br>
         }<br>
    <br>
    /*<br>
         public static void main(String[] args) {<br>
              File testfile=new File("c:\\instance.xml");<br>
              File testout=new File("C:\\testout.txt");<br>
              FileInputStream fis = null;<br>
              FileOutputStream fos= null;<br>
              OnlyLineConvertAddingBOM myFI=new OnlyLineConvertAddingBOM();<br>
              try {<br>
                    fis = new FileInputStream(testfile);<br>
                     fos = new FileOutputStream(testout);<br>
                    myFI.setParameter(null);<br>
                    myFI.execute(fis, fos);<br>
              } catch (Exception e) {<br>
                   e.printStackTrace();<br>
              }<br>
                    <br>
                    <br>
         }<br>
         */<br>
    <br>
    }<br>
    --cut---
    <br>
    This Mapping searches all "ENTRY"-Tags within the XML-Strucure and creates a big string which startes with the UTF-8-BOM and than combined each ENTRY-Element, separated by CR/LF.<br>
    <br>
    We use this as Payload for an Mail-Adapter (sending via SMTP) but it should also work on File-Adapter.<br>
    <br>
    Hope it helps.<br>
    Rene<br>
    <br>
    Besides: could someone tell SAP that this editor is the WORSEST editor I've ever seen. Maybe this guys should copy somethink from wikipedia :-((
    Edited by: Rene Pilz on Oct 8, 2009 5:06 PM

  • 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....

  • Encoding Problem - can't read UTF-8 file correctly

    Windows XP, JDK 7, same with JDK 6
    I can't read a UTF-8 file correctly:
    Content of File (utf-8, thai string):
    &#3648;&#3617;&#3655;&#3604;&#3648;&#3621;&#3639;&#3629;&#3604;&#3586;&#3634;&#3623;
    When opened in Editor and copy pasted to JTextField, characters are displayed correctly:
    String text = jtf.getText();
    text.getBytes("utf-8");
    -32 -71 -128 -32 -72 -95 -32 -71 -121 -32 -72 -108 -32 -71 -128 -32 -72 -91 -32 -72 -73 -32 -72 -83 -32 -72 -108 -32 -72 -126 -32 -72 -78 -32 -72 -89
    Read file with FileReader/BufferedReader:
    line = br.readLine();
    buffs = line.getBytes("utf-8"); //get bytes with UTF-8 encoding
    -61 -65 -61 -66 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    buffs = line.getBytes(); // get bytes with default encoding
    -1 -2 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    Read file with:
    FileInputStream fis...
    InputStreamReader isr = new InputStreamReader(fis,"utf-8");
    BufferedReader brx = new BufferedReader(isr);
    line = br.readLine();
    buffs = line.getBytes("utf-8");
    -17 -65 -67 -17 -65 -67 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    buffs = line.getBytes();
    63 63 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    Anybody has an idea? The file seems to be UTF-8 encoded. What could be wrong here?

    akeiser wrote:
    Windows XP, JDK 7, same with JDK 6
    I can't read a UTF-8 file correctly:
    Content of File (utf-8, thai string):
    &#3648;&#3617;&#3655;&#3604;&#3648;&#3621;&#3639;&#3629;&#3604;&#3586;&#3634;&#3623;
    When opened in Editor and copy pasted to JTextField, characters are displayed correctly:
    String text = jtf.getText();
    text.getBytes("utf-8");
    -32 -71 -128 -32 -72 -95 -32 -71 -121 -32 -72 -108 -32 -71 -128 -32 -72 -91 -32 -72 -73 -32 -72 -83 -32 -72 -108 -32 -72 -126 -32 -72 -78 -32 -72 -89 These values are the bytes of your original string "&#3648;&#3617;&#3655;&#3604;&#3648;&#3621;&#3639;&#3629;&#3604;&#3586;&#3634;&#3623;" utf-8 encoded with no BOM (Byte Order Marker) prefix.
    >
    Read file with FileReader/BufferedReader:
    line = br.readLine();
    buffs = line.getBytes("utf-8"); //get bytes with UTF-8 encoding
    -61 -65 -61 -66 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    buffs = line.getBytes(); // get bytes with default encoding
    -1 -2 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    Read file with:
    FileInputStream fis...
    InputStreamReader isr = new InputStreamReader(fis,"utf-8");
    BufferedReader brx = new BufferedReader(isr);
    line = br.readLine();
    buffs = line.getBytes("utf-8");
    -17 -65 -67 -17 -65 -67 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14
    buffs = line.getBytes();
    63 63 32 0 64 14 33 14 71 14 20 14 64 14 37 14 55 14 45 14 20 14 2 14 50 14 39 14 These values are the bytes of your original string UTF-16LE encoded with a UTF-16LE BOM prefix.
    This means that there is nothing wrong (the String has been read correctly) with the code and that your default encoding is UTF-16LE .
    Edited by: sabre150 on Aug 1, 2008 5:48 PM

  • The use of CL_ABAP_CONV_OUT_CE to create an unicode-16 (UTF-16) file

    Hello,
    I have to create a file iwth normal text in UTF-16 format. In ABAP the creation of an UTF-8 file is very easy (open dataset for output in UTF-8).
    However UTF-16 is barely documented. and the normal open dataset does not support utf-16.
    The only thing i could find out that you have to use class CL_ABAP_CONV_OUT_CE for it and open it as BINARY.
    But i don't know how to do it. Could someone help. an small example would be perfect.
    Thanx in advance.
    Regards, Frank

    Hi,
    Please check this piece of code
    DATA conv TYPE REF TO cl_abap_conv_in_ce.
    DATA buffer(4) TYPE x.
    DATA text(100) TYPE c.
    buffer = '41424344'.
    conv = cl_abap_conv_in_ce=>create(
    encoding = 'UTF-8' ).
    conv->convert(
    EXPORTING input = buffer
    IMPORTING data = text ).
    write: / text.
    Example for class cl_abap_conv_out_ce.
    data: text(100) type c value 'ABCD',
    conv type ref to cl_abap_conv_out_ce,
    buffer type xstring.
    conv = cl_abap_conv_out_ce=>create(
    encoding = 'UTF-8'
    endian = 'L'
    call method conv->write( data = text n = 4 ).
    buffer = conv->get_buffer( ).
    write:/ buffer.
    Also
    you do not need to replace TRANSLATE ... TO UPPER/LOWER CASE in Unicode systems.
    You just need to take care that the arguments fit:
    The arguments of these instructions must be single fields of type C, N, D, T or STRING or structures of character-type only.
    Regards
    Hiren K.Chitalia

  • UTF-8 file via process chain doesn't load

    Hello all!
    I've a big problem. I try to load a UTF-8 file via process chain. I have a script which generate the correct name and the process chain will load the file daily. The file format is UTF-8. I've created a info package with the adapter OPEN_DS load text type file from application server and the character set is 4110 (Unicode UTF-8) but it doesn't work. I try it directly - not via routine - and it works perfect but I can't load with the adapter GUI-UPLOAD load text type file from local workstation via process chain.
    I switched the code page back to 1100 sap internal ISO 8859-1 but with this settings I have a lot strange chars in my texts. Any solutions?
    Regards, Thomas

    Hi,
    no solution?
    Regards, Thomas

  • Upload UTF-16 files to SAP

    Hello All,
    I have some files which are in UTF-16 format generated from Oracle, and need to upload to SAP. Can I ask how to read the UTF-16 files in ABAP program.
    I am now using "OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING UTF-8 .", it fail with the error "converted from code page '4110' to '4103' ". Are there any other ways to read the UTF-16 files from server?
    Many Thanks,
    Sunny

    Hi,
    Refer to the following link for UTF-16 files.
    http://kwanmo.wordpress.com/2008/02/12/abap-read-unicode-file/
    Hope it will help you.
    Jatender

  • How to create an UTF-8 file.

    Hello,
    I want to create a file with an UTF-8 encoding, but I am experiencing a lot of problems.
    The problem is not in the encoding of the content but in the encoding of the file. What is happening is that if I open the file with an editor (ex. ULTRA-Edit), it doesn�t recognize the file as an UTF-8 file and some strange characters are displayed.
    However, if I tell the editor that the file is a UTF-8 file the content is displayed as desired.
    The content that I want put in the file is a XML, and I did another test. I open the file in a web browser, and it displays the characters in a correct way. Considering this, I can conclude that the content is well encoded, and the encoding of the file is not defined (maybe I have to put something in the header of the file that indicates the encoding of the file)
    For me, it works fine in the web browser, because the encoding is defined in the preamble of the XML file, which indicates that the following content is encoded in UTF-8.
    Does anybody know how to define the encoding in the file in order to say to the editor in which encoding the information is coded?
    Regards,
    Rui Torres

    If you write a text file (i.e. not a XML file) using the UTF-8 encoding and the editor of your choice does not correctly recognize the encoding, then it is not to blame.
    The problem is that there is no "magical marker" that tells the editor that the file is in UTF-8 encoding. For the editor it's just a stream of bytes and it tries to make as much sense of it, as possible.
    And it can guess correctly or it can guess incorrectly, but since the "correct" encoding is never stored it can never be 100% sure that it got it right.
    Read [this excellent introduction into Unicode|http://www.joelonsoftware.com/articles/Unicode.html] to learn more about the "plain text" myth.
    With XML it's a bit different. The correct encoding is written in the header (*) and there are heuristics that guarantee that the header can be read correctly if its written in one of the common encodings. So if you use a good XML library to produce your XML file, then you can depend that any software that uses an equally good XML parser can correctly identify the encoding used for it.
    The solution to this problem is simple: always make sure that the encoding of any text file is explicitly known. Either use a format that automatically guarantees that (such as XML), or standardize it for your application ("my application reads and writes *only* UTF-8" (+)) or store the information about each texts encoding somewhere together with the text.
    (*) of course the information in the header could be wrong, but then someone went to the trouble of actually writing the wrong value there. That's a plain old software bug, then.
    (+) this is only a half-way solution since your text files might be used with some other tool than your software and then the same problem would occur again.

  • Probs with read-in of UTF-16LE file

    hi all,
    the following code works only on a small UTF-16LE file, but not on a file of say > 100 KB... with such a file the first isr.read() causes the program to hang...! wrapping with BufferedReader does not solve the prob...
    InputStreamReader isr = new InputStreamReader( new FileInputStream("filename"), "UTF-16LE");
    for( int i = 0; i < 50; i++ ){
    int ch = isr.read();
    System.out.println( "char " + i + ": " + ch );
    FLUMMOXED... PLS HELP!!

    Simple example
    try {
            BufferedReader in = new BufferedReader(new FileReader("FileName.txt"));
            String str;
            while ((str = in.readLine()) != null) {
                //do whatever whith str       
            in.close();
        } catch (IOException e) {
            //Handle Exception...

  • Why linebreak when i write to file???

    When my encryption program returns the encrypted string and I write that string to a file, it producces a linebreak if my string is to long?? why? can someone please help me. I can't decrypt my file cause i read each line and decrypt it seperate.
    the code:
    public class DesEncrypter {
    Cipher ecipher;
    Cipher dcipher;
    // 8-byte Salt
    byte[] salt = {
    (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
    (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
    // Iteration count
    int iterationCount = 19;
    DesEncrypter(String passPhrase) {
    try {
    // Create the key
    KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
    SecretKey key = SecretKeyFactory.getInstance(
    "PBEWithMD5AndDES").generateSecret(keySpec);
    ecipher = Cipher.getInstance(key.getAlgorithm());
    dcipher = Cipher.getInstance(key.getAlgorithm());
    // Prepare the parameter to the ciphers
    AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
    // Create the ciphers
    ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
    dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
    } catch (java.security.InvalidAlgorithmParameterException e) {
    } catch (java.security.spec.InvalidKeySpecException e) {
    } catch (javax.crypto.NoSuchPaddingException e) {
    } catch (java.security.NoSuchAlgorithmException e) {
    } catch (java.security.InvalidKeyException e) {
    public String encrypt(String str) {
    try {
    // Encode the string into bytes using utf-8
    byte[] utf8 = str.getBytes("UTF8");
    // Encrypt
    byte[] enc = ecipher.doFinal(utf8);
    // Encode bytes to base64 to get a string
    return new sun.misc.BASE64Encoder().encode(enc);
    } catch (javax.crypto.BadPaddingException e) {
    } catch (IllegalBlockSizeException e) {
    } catch (UnsupportedEncodingException e) {
    } catch (java.io.IOException e) {
    return null;
    public String decrypt(String str) {
    try {
    // Decode base64 to get bytes
    byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
    // Decrypt
    byte[] utf8 = dcipher.doFinal(dec);
    // Decode using utf-8
    return new String(utf8, "UTF8");
    } catch (javax.crypto.BadPaddingException e) {
    } catch (IllegalBlockSizeException e) {
    } catch (UnsupportedEncodingException e) {
    } catch (java.io.IOException e) {
    return null;

    Hi,
    The Base 64 encoder breaks it's output into lines. I seem to remember that the default is at 72 characters.
    Why not create logical lines? You could end each logical line with a character of your own choosing (one that is not in the Base64 set). Then read lines lines until your logical end of line is reached.
    Roger

  • Issue with the sender file interfaces when using UTF-8 files

    Hello experts,
         We are having number of File to SAP interface scenarios in our business process. In the past, we are having the files coming to us in ASCII text format. Recently, because of the business process change(to handle multiple languages like Chinese), we are getting now the same files in UTF-8 format. So, we have changed the attribute File Type in the sender communication channel from Binary to Text and used encoding format as UTF-8.
    Now, when we see the processed files in PI, we are missing the Header record in the message. For example, we have the PO interface in the following format:
    Identifier     Information
    H     PO header information
    I     PO Item information
    I     PO Item information
    Once the file adapter picks this format kind of file and when we see the XML message in PI, it is just having only two Items information. The header part is not coming to PI at all and the message is trying to get processed inside SAP and therefore interface is failing.
    Additional observations made:
    u2022     We have checked the Document Offset field value too; it is initial for the interface.
    u2022     We added an empty line in the UTF-8 text file, it worked fine. But, this is not an ideal solution for us, because the system which generates these files, canu2019t handle it.
       Does any one has observed this kind of problem before? If so, can you please help me ...
    Thanks,
    Adithya K

    Thanks for all the information. Currently i've tried to use both modules (TextCodepageConversionBean and XMLAnonymizerBean) in my Sender File Adapter, but for now without any result...
    To describe the situation: i am using flatfiles which i am fetched from the file system (NFS) by the Sender File Adapter. To translate the characters to the XML strucutre, the File Content Conversion protocol is been used.
    The content conversion defines the structure base on the first two characters on each row in the flat file. This worked fine till one of our suppliers is delivering BOM characters like "EF BB BF" in the beginning of the file.The content conversion is not able to recognize my header characters in this situation, which will normally start with "01".
    Any suggestions?

  • UTF-8 files with BOM chrashes DOMParser?

    Hi.
    We are storing XML-documents in an 8i databse with UTF-8 encoding (in CLOBS).
    Problem: If the Unicode XML-document contains a BOM the oracle.xml.parser.v2.DOMParser's
    parse()-method throws an exception.
    I get the following output when using the ParseXMLFromURL.java class supplied in JDeveloper 3.2 samples directory:
    Sample output >>>>
    System Output: XML parse error in file http://localhost/UTF-8_With_BOM.xml
    System Output: at line 1, character 1
    System Output: Start of root element expected.
    <<<<<<< Sample output
    If I change the XML-file not to include a BOM the parser works fine.
    (I set/unset the BOM using EmEditor from http://www.emurasoft.com/ if you'd like to try for yourselves).
    To me it looks like DOMParser interprets the BOM at the start of the XML-file as XML-content instead of a Unicode signature.
    IE 5.5 can handle both formats, shouldn't DOMParse also be able to handle that?
    Any ideas how I can get DOMParse to work with UTF-8(BOM) XML-files?
    Regards,
    Jan-Erik
    Sample XML:
    <?xml version="1.0" encoding='UTF-8'?>
    <newsdoc>
    <news>
    <newstitle>
    Document contains no BOM
    </newstitle>
    <introduction>
    See http://www.unicode.org/unicode/faq/utf_bom.html for info on BOM
    </introduction>
    </news>
    </newsdoc>
    null

    I have the same problem when trying to store UTF-8 encoded XML files with BOM marks in iFS version 1.1.9.0.7.
    The database is 8.1.7.1.1 created with UTF-8 charset.
    I have loaded the XDK for PLSQL 9.0.2.0.0A into the database and replaced the original %ORACLE_HOME%\lib\xmlparserv2.jar with the one distributed in this XDK.
    I get the following error message:
    Wed Aug 01 10:10:06 GMT+02:00 2001: \public\CV-Bank\CV_Patrik_Johansson_intDTD_BOM.xml:
    oracle.ifs.common.IfsException: IFS-12608: Error while pre-parsing with the SAXParser: at line (1), column (1): oracle.xml.parser.v2.XMLParseException: Start of root element expected.
    at oracle.ifs.beans.parsers.IfsXmlParser.preParse(IfsXmlParser.java, Compiled Code)
    at java.lang.Exception.<init>(Exception.java, Compiled Code)
    at oracle.ifs.common.IfsException.<init>(IfsException.java, Compiled Code)
    at oracle.ifs.common.IfsException.<init>(IfsException.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.preParse(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.getParserName(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.parse(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.parse(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.utils.common.ParserHelper.parseExistingDocument(ParserHelper.java, Compiled Code)
    at oracle.ifs.protocols.ntfs.server.FileProxy.parseFile(FileProxy.java, Compiled Code)
    at oracle.ifs.protocols.ntfs.server.FileProxy.cleanupFile(FileProxy.java, Compiled Code)
    at oracle.ifs.protocols.ntfs.server.FileProxy.runFileProxy(Native Method)
    at oracle.ifs.protocols.ntfs.server.FileProxy.run(FileProxy.java, Compiled Code)
    This is a serious problem since we use an XML editor that adds BOM's.
    Regards
    Patrik Johansson

  • UTF-8 file encoding issues within Java?

    I'm working on an application that takes data from an IBM mainframe(z/OS), converts it from IBM-1047 encoding to UTF-8(via iconv utility) and binary FTP's it to a Unix box where we process the file with our Java app and return the processed file.
    Within our Java app on the Unix platform we stream the file into a byte array and then create a new String from the byte array specifying "UTF-8" as the encoding parameter.
    The problem is that Java appears to be taking certain 2 byte UTF-8 characters and converting them to a single char.
    E.g. I have a \uC3A6 char in the input file, I can view the bytes in the byte array that's read in, and it's still a \uC3A6, but as soon as I create the new String with UTF-8 encoding and view the bytes, those 2 bytes are now shown as a single byte(0xE6). The code I have that's looking for the char \uC3A6 then fails.
    Can anyone explain what's happening here?? Sorry for the long message.

    The encodings which convert the character (char)0xC3A6 to the 2-entry byte array {0xC3, 0xA6} (unsigned) are "UTF-16BE", "UnicodeBigUnmarked", and "UnicodeBig." These are essentially identical except for the use of byte-order mark. As was said above UTF-8 converts (char)0xC3A6 to the 3-entry byte array {0xEC, 0x8E, 0xA6} (unsigned).
    http://java.sun.com/j2se/1.4.1/docs/guide/intl/encoding.doc.html

  • Manually adding BOM to UTF-16LE file?

    hi.
    i have a bash script that needs to preform something on a string from standard input, save it in a file and convert the file to UTF-16LE with BOM for further processing by another application.
    i use iconv to convert the text file to UTF-16LE, but iconv actually creates a little-endian file WITHOUT the bom. (converting to UTF-16 creates a big endian file WITH bom)
    i see no way of creating LE with BOM with iconv, so i thought maybe i could simply add the byte-order marks (FF FE) to the beginning of the unicode file. how can i do that?
    many thanks in advance
    tench

    If you want to do everything from within bash script, then you can use something like
    {code}
    #!/bin/sh
    # I think xpg_echo is ON by default, but just in case...
    shopt -s xpg_echo
    cat > infile
    # assume the input is in UTF-8
    (echo '\xFF\xFE\c'
    iconv -f UTF-8 -t UTF-16LE infile) > outfile
    {code}
    Of course use of infile can be omitted if you don't need it.

  • Problem opening UTF-8 files in Netbeans 3.5

    Text files with UTF-8 encoding are not opened properly in Netbeans 3.5 IDE. Netbeans interpret them with default charset (wich is Cp1251 in my case).
    I could not find any settings for chaset niether in IDE nor in ide.cfg file. Playing with "-locale" parameter in ide.cfg did not help at all.
    Is there any solution?
    Thanks in advance.

    Right click on the file in Filesystem or Project view, click on Properties in the pop-up menu, set UTF8 for Text Encoding.

Maybe you are looking for

  • SUP - Update KB3000850 and other issues

    Hello, I manage a SCCM 2012 R2 Infrastructure. I am trying to add the KB3000850 to my update package and I always get an error message. I tried to resynchronize the SUP and still the same error. Package: Success: The software updates were placed in t

  • Overwrite existing file not working for FTP

    Hi XI Folks, I am trying not to overwrite the file at receiver - FTP server. It is getting overwritten though I uncheck 'Overwrite existing file' checkbox in FTP. But the same is working fine for NFS. Please find the config details below. Receiver co

  • Microsoft SQL Server JDBC Drivers 4.0.2206 timeout on first connection to SQL Server Express after it sleeps

    Our builds kick off and run integration tests. They are configured to hit a SQL Server Express server. If the builds have been quiet for a while, the first test to connect fails after stalling for 20 minutes. Subsequent tests are fine. Reversing test

  • Forms and Signatures

    My goal is to utilize a Form in order to collect attendance, as well as individual meeting information for activities.  A signature needs to be added as validation of the meeting.  Is there a way to add a signature collection/ feature at the end of t

  • Bt line phone rental

    Ordered bt lime and broadband Problem I asked to pay £120 line rental saver Asked twice and was told can't do it till line is live Can't do it beforehand If this is the case do you phone or online