Parsing unicode escape codes

Hi,
I'm looking for a way to covert a string, wich is read from a file, containing unicode escape codes.
In short this means the file contains a string e.g. "Some text\nOn a new line" which i want to get into a String object as if it was the result of
String s = new String("Some text\nOn a new line"); I've been looking in the java docs but didn't find a function to do that conversion (though the compiler has to do it all the time...).
Any ideas?

Thats not what i'm looking for.
What i've got is a file that look like this:
1="Somestring"
2="another message\nAnd some more text"
3="text with\tTabs\n\tTo get some layout"
etc...
It's used as a stringtable for a program that has to be aviable in multiple languages. There versions of the file in different languages.
What i want is to be able to get e.g. string number 2 out of it in such way that System.out.println(string2); will give the following result:
another message
And some more text
instead of:
"another message\nAnd some more text"

Similar Messages

  • Chinese characters to Unicode Escape

    I'd like to implement a function that convert Chinese string into Unicode escape codes. Just like what the native2ascii doing.
    I can convert single bytes with charToHex but have no clue on dealing double byte character. Any hints?

    I think unicode escapes can be obtained through the tool Native2Ascii from a file. However, if you would a code, the following might be an example.
    public class UnicodeTool{
    static String byteToHex(byte b) {
          // Returns hex String representation of byte b
          char hexDigit[] = {'0', '1', '2', '3', '4', '5', '6', '7','8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
          char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
          return new String(array);
       }   // end of method byteToHex
        static String charToHex(char c) {
          // Returns hex String representation of char c
          byte hi = (byte) (c >>> 8);
          byte lo = (byte) (c & 0xff);
          return byteToHex(hi) + byteToHex(lo);
       }   // end of method charToHex
    static String toUnicodeFormat(char c){
               // int n = (int)c;
               //String body = Integer.toHexString(n);
               String body=charToHex(c); 
                String zeros = "000";
                 return ("\\u" + zeros.substring(0, 4-body.length()) + body);
        } //end of method toJavaUnicodeFormat
    /*   public static void main(String[] args){
        String str = "09Az";//example of a string
        char[] chs = str.toCharArray();
        for(int j=0;j<chs.length;j++)
         System.out.println(toUnicodeFormat(chs[j]));
    }

  • 10g Upgrade - XML Parser errors with certain escape codes (&#x0338)

    NLS_CHARACTERSET = WE8ISO8859P15
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    Since our 10.2.0.3.0 upgrade (from 9.2.0.1.0) our xml fails with the following message:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00217: invalid character 824 (U+0338)
    Error at line 4
    We are using escape codes in our xml that have worked fine on 9i. Example xml:
    <PRINT_LAYOUT_FOOTER>&#x0338;&#x0338;&#x0338;&#x0338;This map was created with Promap</PRINT_LAYOUT_FOOTER>
    I am completely flummoxed - Any ideas?

    You've switched from a Java Based Parser to a 'C' based parser, which is much, much faster. However one of the requirements of the 'C' implementation is that all characters in the database character set. I'm guessing that if you switch to AL32UTF8 for the database character set the problem will go away. BTW 9.2.0.1.0 was desupported for XML related features when 9.2.0.3.0 was released.

  • Wrong translation of escape codes?

    We use the Oracle XSLT processor on Oracle 8i. Problem is, the source document contains escape codes for foreign characters, an example is &#243;
    However, no matter what escape codes we use, the target document, after xsl translation, always translates this into two bytes: BF BF.
    What are we doing wrong? Our source document AND our xsl sheet contain the ISO-8859-1 encodings, and using a download version of the oracle 9i xsl parser in Cooktop produces the correct result (in our example, the escape code is translated into the byte F3).
    Could it be something in the session NLS settings?

    By the way, we store the result document in a CLOB. Maybe this could be the problem?

  • Unicode source code: Umlauts don't work anymore

    So far, i was able to just type (german) Umlauts in my Java source code (String value like
    String text = "�hnlich sch�nes �sterreich"; //sorry about the bad example  ;-)Now I switched my Java IDE (Eclipse) to store source code in UTF-8 Unicode. Since then, my text strings are not displayed as the original Text in Swing anymore (e.g. JTextField) - the Umlauts are replaced by (multiple) strange characters. I thought Java internally handles Unicode?

    to my javac target and now it works. This is really
    strange as the compiler should detect itself what the
    source is encoded in (the Java API itself allows to
    detect the encoding of a file, so why should the
    compiler not be able to do this, to?)Not quite right, the compiler and Java API use the platform's default character encoding like has been mentioned earlier. There is no attempt whatsoever to detect the character encoding; the default is simply used. Now, on your system the default happens to not be UTF-8 while on other systems it is (such as on mine).
    And like mentioned earlier, if you want to write code that can be transferred from one platform to another you should not hardcode non-ascii characters but use unicode escapes.

  • Unicode escapes

    When I get the input of unicode escapes,
    I can work with them as a String, but as soon as I add \u0022 (that is a double quote) to the input,
    then it won't take it anymore, and it says ";" expected.
    Now I am wondering, what is the way around this problem?
    Any advice please?
    public class Unicode
         String uniSt =  "\u0074\u0065\u0073\u0074"; // can't add \u0022 to this string
         // As soon as I add this double quote \u0022, it won't work and would say  ";" expected";
         public Unicode()
              System.out.println(uniSt);
         public static void main (String[] args)
              new Unicode();
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    The unicode value is a double quote and acts as one. If the string has an ending double quote character also, that's an error.
    Use this
    String s = "\u0074\u0065\u0073\u0074\u0022;{code}                                                                                                                                                                                                                                                                                                                                                                                                   

  • Req: Example of report sending a printer escape code

    Hello, I have a batch report that prints student transcripts. After a transcript, I need to tell the printer to staple.
    Please point me to an example of sending a printer escape code.
    By the way I'm printing from Win98 to a Konica 7055 using the postscript driver.
    Thanks!
    Gary C. Whitaker
    St. John Health System
    Information Systems
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by [email protected]:
    hello,
    i have in trouble in same kind of problem if you able to get ride off this problem please help me.
    i have designed a charachter mode report that require a page size height 66 and width 132 portrait mode to print,
    i need to print this report on a generic printer, i have tried various generic printer defination files that are shipped with oracle reports, but the printer prints it according to the page size of height 66 and width 80 becuse of which data gets truncated, however if i send the output a file then it is correct.
    Any body please could tell me what i should do, i am gone blank?
    Thank you in anticipation of reply.<HR></BLOCKQUOTE>
    null

  • How to get the unicode escapes for characters outside a characterset

    Hi!
    I'm tryiing to edit into a RTF file and have been fairly successful so far. But living outside the U.S i need some characters outside ASCII. Those characters are supposed to be escaped as unicode-escapes, eg \u45. But I can't find a way to get the escapesequense for the unicode-characters that lives outside ASCII.
    I'm guessing that this is a very simple thing to do but I have not been lucky with google so far.
    So, how do I get the unicode escapes for characters outside a characterset?
    Thanks in advance
    Roland Carlsson

    I'm tryiing to edit into a RTF file and have been
    fairly successful so far. But living outside the U.S
    i need some characters outside ASCII. Those
    characters are supposed to be escaped as
    unicode-escapes, eg \u45. But I can't find a way to
    get the escapesequense for the unicode-characters
    that lives outside ASCII.You are asking about RTF and not java correct?
    As a guess....
    Unicode is 32 bit (presumably you are not using the newest one.) Thus it requires a 32 bit representation. Thus \u45 actually is the same as \u0045. Thus something like \u1e45 would probably work.

  • Report printing escape codes

    Hi,
    My report comes out with escape codes printed.When I print to file it shows that the escape codes are interpreted correctly BUT they still come out as printable characters when I send to printer. Funny thing is when I output to file then print it using DOS (copy the file to printer port) my report comes out ok with the printer codes interpreted! What could be wrong? sb pls help urgently! I am using reports 6i on WIN2000 platform.
    Mbachi

    You need to set the printer to spool the raw data (and not try and be clever and interpret the escape characters, which is what's happening now). To do this on Windows 2000:
    * Click Start , point to Settings , and then click Printers .
    * Right-click the printer that you want to use and click Properties .
    * On the Advanced tab, click Print Processor .
    * Click Raw in the Default data type box.
    * Click OK to confirm changes.
    * On the Advanced tab, clear the Enable advanced printing features option.
    * Click OK to confirm changes.
    Hope this helps,
    Danny

  • Parse ColdFusion Source Code

    I'm looking for some help in parsing ColdFusion source code,
    say a cfc, to provide some documentation.
    Does anyone have some pointers for me to research?
    dickbob

    > the standard
    > CFC administrator tool is not available on shared
    hosting.
    All the tool does is to instantiate the component and output
    it's metadata
    on a template. There's no special trick to it.
    http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000488.htm
    Adam

  • How to replace & with escape code?

    Hi,
    I want to replace all occurence of & in a string with escape code '%26' . Is the following lines of the code the right way to do this? Please help. Thanks.
    String test;
    test.replace('&', '%26');

    Have you tried it? What was the result?
    Anyway. Looking at the javadoc:
    http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html#replace(char, char)
    I see that replace takes a character and replaces it with another character. So it seems that your fragment won't work. Perhaps you ought to look at:
    http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html#split(java.lang.String)
    and try something like (untested code):
    String someString = "This & is & a Str&ing";
    String[] elements = someString.split("&");
    StringBuffer buffer = new StringBuffer( elements[0] );
    for ( int i = 1; i < elements.length; i++ ) {
        buffer.append( "%26" );
        buffer.append( elements[i] );
    someString = buffer.toString();Optimization is left as an excercise for the pedantic reader.

  • Escape codes for laser printer Kyocera FS-3920dn in reports 6i

    Hi,
    I use many reports for printing on laser printer Kyocera FS-3920DN. But now I need print some reports on special performed paper. For this we added 1 paper tray to printer ( Now we have 2 trays in printer ). How can I define for new reports which tray have to use ??? I wish to specified for report2.rep to use automaticly tray 2. Its a way through PRT file use escape codes ?? Have you any experience pls??

    In the report itself you can use:
    SRW.SET_PRINTER_TRAY('tray');
    see the online help.
    We do it differently, though. Our printers have 2 trays, one with blank paper and one with pre-printed logo paper.
    On each PC there are two printers defined (PRINTER_BLANk and PRINTER_LOGO). They point to the same printer, just a different tray.

  • Parsing Java Source Code

    HI!
    I am searching for an API to parse java source code, modify it (add new methods, change method names,....) and write it to a new file.
    any suggestions?
    mfg
    MK

    there is no such Java API

  • How can I get unicode escape for £ in java

    Is there any API which can translate the symbol &pound; to its corresponding unicode escape?

    SurfManNL wrote:
    Found one as well, but in the currency secion: 20A4
    http://www.unicode.org/charts/PDF/U20A0.pdf
    That's for Italian Lira, which has been replaced by the Euro some years ago ;)

  • Element type attributes doesn't accept HTML escape codes in 10.1.4

    In 9.0.4 we often used HTML escape codes in attribute values for element types when we needed to use special characters, for instance using &laquo; becomes « and so on.
    In 10.1.4 however, this doesn't seem to work any longer. For instance &laquo; becomes
    &amp;laquo; which of course looks like garbage when you use the element type on a page. Anyone found a workaround to this ?

    The workaround I've been using is running
    ttyctl -f
    as early as possible in my zshrc.
    stty will be non-functional while ttyctl is freezing the terminal settings but in my case, since I'd never even heard of that command prior to my searches in finding a fix, I can't say it really bothers me. At least I can run yaourt now without having my terminal messed up. If you do use stty often, here's a function that'll unfreeze the terminal settings first.
    Last edited by qwerty12 (2014-08-30 08:46:21)

Maybe you are looking for

  • Bt Infinity New contract started Very Very Slow in...

    Hi Just wondered if anyone can give any help. Ive swapped to BT Infinity in the last week but my evening connection is very slow. If I check speed in the morning it will be at 37/38 Mbps.  After 4pm of an evening speed drops to 3-6 Mbps. Ive cotacted

  • Can I over-ride thrColFixHdr.css template for homepage only?

    My site, http://isuckatgolf.net has a thrColFixHdr.css template used throughout the site. Which is fine for every page but the homepage. I want the homepage to be wide open so I can make a landing page more like a newpaper effect and not be restricte

  • Using a form control (textbox) as an SQL Server parameter

    Hi i am trying to use a form textbox control to filter an SQL query but i do not know how to do this. In fairness, im from an Access background originally and can easily do it in Access lol. Is it better to connect to the SQL database using code and

  • I have acrobat 9 Prof and the Sticky Notes will not work

    I have some PDF's that I need to add some sticky notes to but can't! Any idea on what I need to do to fix this issue?

  • Export procedure not fill in automatic

    Hi Gurus, I have some problems with the export procedure in SAP. I have done the customizing on the "Define procedures and Default Value" in the Basic data for foreign trade menu, but when I create a new invoice, this information is not fill in autom