Read/Write file in Unicode (UTF-16)

Hi, I have some issue to write a file in Unicode (UTF-16)
I have to read a file with LabView, change some parameters and write the new data into the same file. The file uses Unicode UTF-16.
I downloaded some library here: https://decibel.ni.com/content/docs/DOC-10153
I can read the file, convert the data to UNI/ASCII/UNI, and then write the file. But when I open the new file with an editor like Notepad++ there are some unexpected characters at the end of the line.
Even reading the file and writing exactly the same data doesn'not work.
I attached an example.
Thanks for you kind support.
Solved!
Go to Solution.
Attachments:
TEST.zip ‏7 KB

Right-click on your Read and Write Text File functions.  There is an option to "Convert End Of Line".  Turn that off on both functions.
As a side not, you don't need the Close File functions.  The Read and Write Text File functions will close the file if the file reference output is not wired.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • How to save a file in unicode (UTF-8)

    Hello,
    I'm trying to save a xml file in unicode (UTF-8) in a 4.6C system. I tried the OPEN DATASET 'file' IN TEXT MODE FOR OUTPUT ENCODING UTF-8 but this is not available in 4.6C. Does anybody have an idea how to do this?
    Thanks in advance
    Kind regards
    Roel

    Hi Roel,
    There is a workaround for this issue.
    Use code below:
    encoding = 'utf-8'.
      data: codepage            type cpcodepage.
      call function 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
        exporting
          external_name = encoding
        importing
          sap_codepage  = codepage
        exceptions
          not_found     = 1
          others        = 2.
      if sy-subrc <> 0.
      endif.
      call function 'SCP_TRANSLATE_CHARS'
        exporting
          inbuff           = sourcedata_xml
          inbufflg         = length
          incode           = codepage
          outcode          = codepage
          substc_space     = 'X'
          substc           = '00035'
        importing
          outbuff          = custom_data
        exceptions
          invalid_codepage = 1
          internal_error   = 2
          cannot_convert   = 3
          fields_bad_type  = 4
          others           = 5.
    Now write this custom_data onto application server by using open dataset and transfer.
    Also have a look at this weblog, there is a code sample in it.
    /people/thomas.jung3/blog/2004/08/31/bsp-150-a-developer146s-journal-part-x--igs-charting
    Hope it'll help.
    Cheers
    Ankur

  • How to read write file in HTML5 extension

    Hi,
    I think it could be very generic question since moving from Flex to HTML5 extension is loosing ability to read write a file in local file system.
    I'm trying to write a log file within extension space but It throws error as 'TypeError: Illegal constructor'
    new File(csInterface.getSystemPath(SystemPath.EXTENSION)+"/log/Log_"+.getCurrentDateString+".txt");
    does someone have solve for this.
    Thanks in advance
    MM

    Yeah, It could be a reason for nested error but I got the error right before executing "getCurrentDateString". But I kind of figured it out as Javascript looses ability to read write file in user file system except Crome browser, you can read more here. However Adobe has added fs API within CEP which allows user to read and write file in user system.
    Here is some peace of code on how to do it, complete API reference check here :
    var result = window.cep.fs.writeFile(logFilepath, "Your data goes here");
      if(result.err != 0)
      throw new Error("Result object has error");
    However still this does not provide any method to append the content in existing file as a result if you wanted to write kind of log file, every time you need to first read the file and then concatenate your content to file data then write data again to new file. sound hefty to append content?
    I'm hoping if any Adobe staff has any comment on this.
    Thanks
    MM

  • IO Operation (read/write files) in IPAD AIR downgrade ~50% than the one in IPAD4

    Summary:
    UnZip the same file with the same native unzip method (native zlib) in IOS7, ipad air take +50% more time consumption than the one in iPAD4.
    for unZip, it main perform the IO read/write files in ipad, does apple air already changes the file system ?
    Steps to Reproduce:
    UnZIP a file with native zlip on both ipad AIR and IPAD 4 :
    IPAD AIR: 16GB
    IPAD 4: 16GB
    ZIP file size: 700KB
    Files in zip file: 225 files (120 files are images)
      after remove the images, the time on IPAD AIR will save 50% time consumption
    unZip method: the native zlib
    unzip time on IPAD AIR+ IOS7: ~1200ms
    unzip time on IPAD 4+ IOS7: ~800ms
    Expected Results:
    The unzip time should be almost the same on IPAD AIR and IPAD4.
    Actual Results:
    For same IO operation read/write file, IPAD AIR gets the 50% downgrade performance than the one in IPAD4
    Version:
    IPAD4: 16GB WIFI + IOS7
    IPAD AIR: 16GB WIFI + IOS7
    does anyone else encounter the same problem ?
    A bug already submitted for apple: https://devforums.apple.com/message/993060

    I even tried porting the code to Gumbo and running it there - still, no fonts are being enumerated.
    If you're too lazy to read the whole above post, here's the problem in one sentence
    An SWF that contains a textfield with embedded fonts, when launched by itself succeeds to return the embedded font using Font.enumerateFonts(false), however when loaded using Loader.loadBytes into AIR, it fails to see those fonts even though the textfield in it is displayed and editable.
    How do I make the loaded child application and AIR see the embedded font?

  • Help with Read/Write File

    hi I was wondering if someone can help me do some read/write file with java. here is what I want to do:
    Read a file and search the whole file for a word such as "throw" and print out the rest of that line to a new file. in the case of "throw", i want to link all thrown exceptions to the file that contained them.
    can someone help me out and let me know what way I can approach in this?
    any help would be greatly appreciated.
    thanks!

    Rough and dirty, here's a class that will read a file and return a resultset:
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.FileChannel;
    import java.util.*;
    import java.text.DateFormat;
    public class Utils{
         File fileName;
         FileOutputStream outputFile;
         boolean closeChannel;
         //Constructor
         public Utils(String directory, String filename){
              String strFileDir = directory;
              String strFileName = filename;          
              File fileDir = new File(strFileDir);
              fileName = new File(fileDir, strFileName);
              // If directory does not exhist, create it.
              if(!fileDir.isDirectory()){
                   if(fileDir.mkdirs()){
                        System.out.println(fileDir + " created.");
                   else{
                        System.out.println(fileDir + " could not be created.");                    
    public ArrayList readText() throws IOException{          
              // Read content of file into a collection
              ArrayList arrayList = new ArrayList();
              try{
                   BufferedReader in = new BufferedReader(new FileReader(fileName));
                   String line;
                   while((line = in.readLine()) != null){
                        arrayList.add(line);
                   in.close();               
              catch (IOException ex){
                   throw ex;
              return arrayList;          
         }And here's how you use the class:
    // Create a new Disk Utilities object.  This can be used for all subsequent read/writes to this file.
              Utils utilTest = new Utils("e:/testing", "Testing.txt");
    // Create a collection to hold the data from the file.
              ArrayList arrayList = new ArrayList();
              try{arrayList = utilTest.readText();}catch(IOException ex){ex.printStackTrace(System.err);}

  • How To read/write file on remote server in java

    Hi All,
    How To read/write file on remote server in java? I mean using URL - http://www.xyz.com can I right file to that perticular server.
    Thanks in advance

    If your server support a means of uploading files you can.
    A popular means is [http://en.wikipedia.org/wiki/WebDAV]
    However, by default web server don't allow you upload files, its usually something you need to configure or install.
    I suggest you have a look at your web servers documentation.

  • Reading TemSe files in unicode system showing greek letters

    Hi Gurus,
    I am facing issue with the newly converted unicode (cp 4102) spool files. I am using the standard functions RSTS_OPEN_RLC , RSTS_READ and RSTS_CLOSE to read TemSe files and create output files on application server using OPEN DATASET and TRANSFER.
    After conversion to unicode, these function calls are returning some greek characters with size of the itab doubled (and that is due to double-byte UTF-16 charcter set) .
    The program generates
    Runtime Error          CONVT_CODEPAGE
    Except.                CX_SY_CONVERSION_CODEPAGE
    " While a text was being converted from code page '4102' to '1100', on
    the following occurred:
    - an character was discovered that could not be represented in one o
    the two code pages;
    - the system established that this conversion is not supported."
    the statement
    TRANSFER TEMSE_DATA TO ACT_FILE
    generates this error.
    Can someone tell me what is missing ?
    TIA
    Wasim

    The extra characters are pasted below:
    ㄀  㤀㄀    ㈀㈀㄀㐀㄀ ㈀㜀㐀㐀㐀  㤀 ㈀ 㘀 㤀㈀ 圀 㤀㐀㄀ ㄀唀⸀匀⸀ 䈀䄀一䬀
    These kind of characters are also visible in SP11 contents for spool files.
    Again the question: which font to you use to display in your SAPGUI?
    The spool files are generated through language EN and should not show any non-english characters.
    That doesn´t tell anything. One advantage of Unicode is that you can enter, display and modify all languages/characters with an English logon.
    Another question: What technology is generating those spool files? Sapscript? Smartforms? Self written program?
    Markus

  • Help with utl_file (read/write file from local directory)

    Need help reading/writing file on local machine from plsql using 10.2 DB.
    I am trying to read/write a file from a local directory(laptop) without success.
    I have been able to read/write to the database server directory but can't write to directory on local machine.
    The utl_file_dir parm has been set to * and the db restarted but I can't get it to work... Here's the plsql statement.
    out_file := UTL_FILE.FOPEN ( 'C:\PLSQL', 'TEST.TXT', 'W' ,32767);
    Whenever I run it continues to write to c:\PLSQL dir on the database server. Have looked at the "Directory" object and created MY_DIR = C:\PLSQL but it writes to the db server.
    Running 10.2 on a remote windows server, running PLSQL using sql*navigator.
    Thanks in advance for your help..

    I don't see how you expect the server to be able to see your laptop across the network, hack into it and start writing files. Even if it could, what if there is more than one laptop with a C: drive? How would it know which one to write to?
    Is there a shared drive on the server you can access via the laptop?

  • How to sign MIDlet so it wont confirm before read/write file operation ?

    hi there,
    i am developing application which reads mp3 files from the songs folder. but at each run of my application it ask the confirmation to Allow to read and write file to application.
    how can i othorize or sign my MIDlet to overcome this problem ?
    i m using Sony Z550i phone.

    on some J2ME platforms you may have to sign the applet to set the option to Always Allow.
    Under NetBeans all you have to do to sign the app is go to the Projects window, right click on the desired project, select Properties. A Project Properties window will pop-up. On the left hand side, near the bottom, select Signing. Select the check box labeled 'Sign Distribution'. By default there is a 'built-in keystore' that should work with many J2ME platforms but you can also generate your own keystores through the Security Manager.
    If you wish to generate your own keys:
    WARNING: may not work with all J2ME platforms if you are not able to authorize the key on the platform you wish to run it on.
    Beside the 'Sign Distribution' checkbox there is a button labeled 'Open Security Manager'. There you click 'Add Keystore'. Fill in a password and it will create your keystore. Next, select the newly generated keystore and click the 'New' button to add keys to the keystore. Simply fill out the form and it will generate a key for you.
    When you build using NetBeans it may ask you for the keystore and signing key passwords again, so make sure you use a password you will remember.

  • How to read, write file inside the JAR file?

    Hi all,
    I want to read the file inside the jar file, use following method:
    File file = new File("filename");
    It works if not in JAR file, but it doesn't work if it's in a JAR file.
    I found someone had the same problem, but no reply.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
    Can you help me ? I have tried this for all night !
    Thanks in advance
    Leo

    If you want to read a file from the JAR file that the
    application is packaged in (rather than a separate
    external JAR file) you do it like this ...
    InputStream is =
    ClassLoader.getSystemResourceAsStream("filename");Better to use
    this.getClass().getClassLoader().getResourceAsStream();
    From a class near to where the data is. This deals with multiple classloaders properly.

  • Applet read/write files

    Hi,
    I have a problem to use getCodeBase to get the URL. Actually, I am pretty confused on running the applet in our intranet.
    Let me explain my problem here, I have mapped a network drive(G:\personA) in my machine and my applet and all the files are in G:\personA\classes. In my coding, I have tried to specify my files paths such as G:\personA\classes\index.txt and I can run the applet without any problem either with Eclipse or from a web site http://personA//report.html. But the other members in this company cannot run this applet thro' this web site( http://personA//report.html). The problem is "No class found", can't find the path G:\personA\classes\index.txt.
    So I decided to change my code by reading/writing files thro URL i,e : http://personA/classes, but when I run my applet, I got the following exception :
    ava.lang.NullPointerException
         at java.applet.Applet.getCodeBase(Applet.java:136)
         at web.MyChart.readAndPrintData(MyChart.java:336)
         at web.MyChart<init>(MyChart.java:113)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at java.lang.Class.newInstance0(Class.java:308)
         at java.lang.Class.newInstance(Class.java:261)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
         at sun.applet.AppletPanel.run(AppletPanel.java:298)
         at java.lang.Thread.run(Thread.java:534)
    does anybody knows how to solve this problem?? Please...
    Thanks,
    Tiffany

    I think a trace would help, guessing is fun but won't solve your problem:
    To turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)

  • Read/write bytes in unicode

    I have the next piece of code:
    String encryptionText = "\u4f45\ueb33\ua4ea\ufcd0\u9e52\u6faf\udcd8\u4aa6";
    File inputText, outputText;
    outputText = new File("outputCod.txt");
    FileInputStream fin;
    FileOutputStream fout;
    String key, text;
    byte[] bufText, bufKey;
    fout = new FileOutputStream(outputText);
    fout.write(encryptionText.getBytes("UTF-8"));
    fout.close();
    inputText = new File("outputCod.txt");
    fin = new FileInputStream(inputText);
    bufText = null;
    bufText = new byte [(int)inputText.length()];
    fin.read(bufText);
    fin.close();
    text = new String (bufText, "UTF-8");
    At the end i want to have in text the same thing as in encryptionText. But I dont. In encrytionText I have "\u4f45\ueb33\ua4ea\ufcd0\u9e52\u6faf\udcd8\u4aa6" and in text I have "\u4f45\ueb33\ua4ea\ufcd0\u9e52\u6faf?\udcd8\u4aa6". Any idea where that "?" comes from? encryptionText.getBytes("UTF-8") and bufText have the same content in the end.

    just_me_n wrote:
    why are they not valid? aren't all valid? \u0000 to \uffff? it;s not quite binary i need to put intro string...i need to put into string any kind of \uxxxx.No, they are not all valid (in particular, the surrogate pair range is treated differently). You should not be putting binary data into a string, only character data.

  • Read/write file located on server

    Hi,
    I want to read a TXT file located on server and depending on the response I want to write an XML file also located on server
    how could be it possible in JAVA
    please help me
    alpesh

    the TXT file is located on the WEB server, and I want
    to read the TXT file's content From the client, I assume. URLConnection. Or your favorite browser.
    the content is the User InformationAnd you want to write that on the server. Forget it, unless you have CGI or FTP or a servlet or whetever to process incoming requests or allows you to connect to the fie system somehow (WebDAV).

  • Read/Write file

    Can anyone tell me how can I read a text file and then write it back after some modifications?

    Hi,
    Check this out.
    http://java.sun.com/docs/books/tutorial/essential/io/filestreams.html

  • Deliver file with read/write properties on target side using receiver file

    Hi All,
    Our file-to-file scenario works fine. By default, PI creates file on target directory with the 644 permissions. Files coming inbound from PI are not read/writable to the group. Currently the files from PI are coming across with 644 permissions and they should be 664 or 660. Is there a way to generate read/write files on targer side using SAP PI??
    Thanks in advance,
    - Riya Patil

    Hello,
    Try using Run-Operating system command after processing parameter with the below mentioned command:
    chmod 0755 /usr/sap/tmp/test/*
    where:  /usr/sap/tmp/test/ is the directory path location.
    Br,
    Rahul

Maybe you are looking for

  • MRP type for two different types requirments( Sale order and PIRs)

    Dear All, We have requirment  some materials we have sales order and PIRs. For sales order we want to consider with "MRP type" as PD and PIR we want to consider "MRP type" as VB manual reorder point planning. Is there any stadard  solution. If standa

  • Updated iPod to 1.2 , now it tells 'use itunes to restore'. How ?

    Hello, sorry my english. I have just updated my iPod nano from firmware 1.1.1 to 1.2 using latest iPod Updater 2006-06-28. It went ok. Then i entered iTunes 6.0.5 and made an eject. The iPod showed "OK to disconnect". I disconnected. But now when I t

  • Loading problem in full screen mode

    When I am in full screen mode and zoomed in (I press the Z key) and I am using the arrow keys to switch between photos in a project, I notice that it often gets stuck saying "Loading..." and does not finish rendering the image that I have switched to

  • Oc4j doesn't start in my local

    Hi I am unable to start in my local. Please help me to start Regards Felix S

  • How are the web gallery engines done?

    Hi, Just interested how the gallery engines are done? I suppose they are using some programming language? Is there some tools available in case I would like try do my own? H.