Displaying unicode or HTML escaped characters from HTTPService in Flex components.

Here is a solution on the Flex Cookbook I developed for
displaying data in Flex components when the data comes back from
HTTPService as unicode of HTML escaped data:
Displaying
unicode or HTML escaped characters from HTTPService in Flex
components.

Hi again Greg,
I have just been adapting your idea for encountering
occasional escaped characters within a body of "normal" text, eg
something like
hellô sunšine
Now, the handy String.fromCharCode(charCode) call works a
dream if instead of the above I have
hellô sunšine
Do you know if there is an equivalent call that takes the
named entities rather than the numeric ones? Clearly I can just do
some text substitution to get the mapping, but this means rather
more by-hand work than I had hoped. However, this is definitely a
step in a useful direction for me.
Thanks,
Richard
PS hoping that the web page won't simply outguess me and
replace all the above! Basically, the first line uses named
entities and the second the equivalent numbers...

Similar Messages

  • Stop escaped characters from resolving within String class.

    Hello,
    Is it possible to stop escaped characters from resolving within the String class?
    For example, I define a character array,
    char[] c = {'0','\\','n'}
    and I want to create a String based on this exact sequence (0\n). However, when I call the String constructor String(char[]), it resolves the \n sequence into the newline character, creating a String of length 2 not 3.
    I'm not very familiar with the innards of the Java compiler (does "xyz" translate to char[]{'x','y','z'}?), so maybe this is something very basic.
    Does anyone know if there is a flag that can be set somehow before I create a String instance (it appears that no String constructor supports this kind flag)?
    Or perhaps is there a method in the standard Java release that escapes all escape characters in a character array...? I'm curious if there is a simpler way (like a flag), because the method approach seems superfluous.
    Thanks,
    Brien

    What do you mean?char[] c = {'0', '\\', 'n'};
    String s = new String(c);
    System.out.println(s);does give the string 0\n...
    And by the way, it's not the String class that transforms \n to the linefeed character, it is the compiler..

  • Reading in/writing out escape characters from/to file

    I am trying to read in a large file which has many escape/special charaters (e.g. /, double quote (" ") etc.). I need to read them as they are and then write them out in a separate file as they were in the original file (e.g. if there was a double quote in the original file, I would have to keep the double quote in the output file)
    Now my question is: how can we tell the BufferedReader and FileWriter not to treat those characters to be escape characters?
    Thanks

    Now my question is: how can we tell the
    BufferedReader and FileWriter not to treat those
    characters to be escape characters?AFAIK, you don't need to do anything special. BR and FW already do that the right way.
    Did you try the standard approach?

  • HTML Escape Characters

    I have some registration forms in my web site, I wan to prevent user from entering HTML tags in input text fields and textareas (actually HTML injection), In fact I want to display the entered info in a way that entered HTML tags don't affect on the appearance of the web site and the actual tags be displayed on the page. I know that the solution is replacing the critical characters in the entered text with their corresponding Escape codes, But is there any class or method which does this for me?
    I know there are such functions in Perl and PHP.
    Regards
    http://behravesh.ws
    Message was edited by:
    Ehsun

    You can use StringEscapeUtils from Apache commons...
    String HTML = "<B>$ to \u00A3 Rate</B>";// Original values
    System.out.println(HTML);
    System.out.println();
    // Conversion examples
    System.out.println(StringEscapeUtils.escapeJava(Java));Produces...
    <B>$ to &pound; Rate</B>

  • Converting HTML Escaping to Unicode Escaping characters in Java

    Hi,
    I am getting some HTML escaping for special characters like pound, space, dollar etc. from database in HTML escaping format as  &apos; &pound;      &reg; etc.which I want to convert their Unicode equivalent escaping as U00A3,U0026. Java only convert & to & (U0026) but rest of the characters are not getting converted. If there is any API or way to do this please reply.
    Note : I cant change Database as there are already thousands of records & My front end only needs Java to do all these conversions I cant change that also.

    I have posted a method that does what you want. It was a long time ago since I wrote it and you should probably use a StringBuilder instead of a StringBuffer if you are going to use it in Java 5 or later. You can find the method in this thread:
    http://forum.java.sun.com/thread.jspa?threadID=652630

  • Create HTML file that can display unicode (japanese) characters

    Hi,
    Product:           Java Web Application
    Operating system:     Windows NT/2000 server, Linux, FreeBSD
    Web Server:          IIS, Apache etc
    Application server:     Tomcat 3.2.4, JRun, WebLogic etc
    Database server:     MySQL 3.23.49, MS-SQL, Oracle etc
    Java Architecture:     JSP (presentation) + Java Bean (Business logic)
    Language:          English, Japanese, chinese, italian, arabic etc
    Through our java application we need to create HTML files that have to display unicode text. Our present works well with English and most of the european character set. But when we tried to create HTML files that will display unidoce text, say japanese, only ???? is getting displayed. Following is the code we have used. The out on the browser displays the japanese characters correctly. But the created file displays only ??? in place of japanese chars. Can anybody tell how can we do it?
    <%
    String s = request.getParameter( "txt1" );
    out.println("Orignial Text " + s);
    //for html output
    String f_str_content="";
    f_str_content = f_str_content +"<HTML><HEAD>";
    f_str_content = f_str_content +"<META content=\"text/html; charset=utf-8\" http-equiv=Content-Type></HEAD>";
    f_str_content = f_str_content +"<BODY> ";
    f_str_content = f_str_content +s;
    f_str_content = f_str_content +"</BODY></HTML>";
    f_str_content = new String(f_str_content.getBytes("8859_9"),"Shift_JIS");
    out.println("file = " + f_str_content);
              byte f_arr_c_buffer1[] = new byte[f_str_content.length()];
    f_str_content.getBytes(0,f_str_content.length(),f_arr_c_buffer1,0);
              f_arr_c_buffer1 = f_str_content.getBytes();
    FileOutputStream l_obj_fout; //file object
    //file object for html file
    File l_obj_f5 = new File("jap127.html");
    if(l_obj_f5.exists()) //for dir check
    l_obj_f5.delete();
    l_obj_f5.createNewFile();
    l_obj_fout = new FileOutputStream(l_obj_f5); //file output stream for writing
    for(int i = 0;i<f_arr_c_buffer1.length;i++ ) //for writing
    l_obj_fout.write(f_arr_c_buffer1);
    l_obj_fout.close();
    %>
    thanx.

    Try changing the charset attribute within the META tag from 'utf-8' to 'SHIFT_JIS' or 'utf-16'. One of those two ought to do the trick for you.
    Hope that helps,
    Martin Hughes

  • Displaying unicode characters

    Dear all,
    I am currently dealing with a character displaying problem on the MAM.
    We will soon go live in China. Until now we only had European countries, with a Latin alphabet.
    Now however this changes, so we need to use Unicode to display all characters correctly.
    Therefor I have converted all our custom language files to language files with Unicode escape characters.
    e.g.:
    EQUIPMENTS_EQU_MAT_NR=设备材料号码
    Now the strange thing is that when we login in Chinese, everything is displayed correctly, but when we login in German or Polish (countries which also have some special characters), we don't see everything displayed correctly.
    This is the code how we display an entry from the language file on the screen:
    <%@page language="java" contentType="text/html; charset=UTF-8"%>
    meta http-equiv="Content-Type" content="text-html; charset=UTF-8"
    <jsp:useBean id="res" class="com.sap.ip.me.api.services.MEResourceBundle" scope="session"></jsp:useBean>
    <%=PageUtil.ConvertISO8859toUTF8(res.getString("CONFIRMATIONS_HEADER_DETAIL"))%>
    For Chinese language, the characters are displayed correctly in this way.
    e.g.: 最后一次同步时间
    However Polish characters and German characters are not (always) displayed correctly.
    e.g.: Wskaźnik pierwszego usuniÄu2122cia usterki
    The only 'difference' that I can see is that for China, every character in the language file has a special Unicode notation, while for Polish and German characters, only the special characters are displayed in special Unicode notation.
    e.g.:
      EQUIPMENTS_EQU_MAT_NR=Numer materia\u00c5‚u sprz\u00c4™tu
    FYI, I've converted the files to Unicode escape characters with the java util native2ascii.exe.
    Is there anyone who knows how to solve this issue?
    Thanks already in advance!
    Best regards,
    Diederik
    Edited by: Diederik Van Wassenhove on Jul 6, 2009 2:34 PM

    Dear all,
    I've found the reason for this problem.
    Thanks anyway for your time!
    The problem was that when converting the language files to Unicode escape characters, the source format was wrong. The files where saved as UTF-8, but the JAVA tool native2ascii is not taking UTF-8 as standard input format. So the resulting Unicode file was not containing the correct Unicode characters.
    I've re-generated the language files with the parameter -encoding UTF-8, and now everything is displayed correctly!
    Have a good day!
    Diederik

  • Display chinese characters from oracle 8i database using UTF-8

    I have written a program to retrieve chinese characters from the database and display in the web page.If I change the encoding of the webpage manully it displays the chinese characters(&#27604;&#20998;&#21345;&#29255; ).Or it shows the junk characters(�������� ).Can anybody help so that do I have to do any encoding or any other settings?.I am using Jdeveloper.
    Rgds
    Ganesh
    <HTML><HEAD><TITLE>Welcome to METRO</TITLE>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <%//@ page contentType="text/html; charset=UTF-8" %>
    <%@ page import="java.io.*,java.io.InputStream,java.nio.*,java.lang.*,java.util.*,javax.naming.Context,java.sql.Connection,javax.sql.DataSource,javax.naming.InitialContext,java.sql.*" %>
    </HEAD>
    <BODY >
    <%
    String value="";
    try{
    Connection dbConn;
    Statement stmt=null;
    Context jndiCtx=new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource)jndiCtx.lookup( "jdbc/webdbPooledDS" );
    dbConn= ds.getConnection();
    stmt=dbConn.createStatement();
    String sql="select prog_name_LL2 from wb_prog_new_metro where table_name='SCORE_CARD'";
    ResultSet rs = stmt.executeQuery(sql);
    if( rs.next()){                    
    value=rs.getString(1);
    out.println(value);
    }catch(Exception e){
    System.out.println("Exception ="+e.getMessage());
    %>
    </BODY></HTML>

    Make sure that you have a Unicode font that supports Chinese characters. I have been testing the support of Unicode text (allows many other character and image based languages to be displayed) and have found that it depends on what fonts are available on the system you're viewing the report on. Unicode is supported in Crystal (since version 9 I believe) but it will display '?' or '[]' if there isn't a font to render the text properly.
    This font supports loads of languages: http://www.code2000.net/code2000_page.htm

  • Problems displaying unicode encodeded characters in components

    I'm having problems getting Flash to display unicode that is
    imported from XML. In the example below the unicode characters in
    the name tag come through in Flash exactly as typed eg: \u00EA
    The xml file is written by PHP.
    <?xml version="1.0"?>
    <!-- Generated On: Sep-11-2007 12:24:19
    --><Colortool><Siding><item><type>c</type><id>11</id><name>Rev\u00EAtement
    Sp\u00E9cial</name>
    etc..
    However I've also tried re-saving the file manually in an
    editor encoded as UTF-8. Same result.
    Setting up a little test like:
    temp = "Rev\u00EAtement de premi\u00E8re qualit\u00E9";
    trace ("temp: " + temp);
    Traces: Revêtement de première qualité as
    expected.
    Any ideas why it works when the variable is set in Flash, but
    not when it's loaded from XML?
    Thanks,
    Anson

    By experimenting and some searching through the net I figured out that you need to set the right font. Kannada can be displayed using Tunga font on windows. But neither HTMLEditor nor TextArea has a setFont() method. Instead I tried with Text.
    text.setFont(Font.font("Tunga", 25.0));
    This worked partially. For example, if I try printing the character 'ಲಿ' its two component characters 'ಲ ಿ' are getting printed. They are not joining to form one single character 'ಲಿ'. Kannada like other Indic scripts is a complex layout script and I figured out from this post that complex layouts are not yet supported.
    Re: Urdu language support in Javafx UI Controls
    Unfortunately I cant use javafx for my purpose :-((

  • How to get UTF-8 Characters from HTML to Java?

    Hi everyone, I'm trying to set up an application that will allow display and entry of international data from HTML forms via servlets. The problem is that I can't get the data back into a java string to apply to the DBMS.
    I have tried using UTF-8 and specific character sets such as ISO-8859-5 (Russian). I have specified these character sets/encodings as follows:
    HTML: meta content-type header charset=xxx and <form accept-charset=xxx
    Servlet Response: setLocale(appropriate locale) and setContentType("text/html; charset=xxx") prior to calling response.getWriter()
    Servlet Request: setCharacterEncoding("xxx") (e.g. servlet 2.3)
    When I use request.getParameter(xxx) I get normal characters (a, b, c) and nothing for international characters or sometimes question marks.
    I have also tried various combinations of:
    new String(request.getParameter("xxx").getBytes("xxx"),"xxx")
    Could someone please point me in the right direction?
    TIA

    Thanks for all of your suggestions. It still refuses to work.
    I entered the following: ���^�E on the HTML form using the Chinese(PRC)keyboard on my Win2K box.
    I checked and verified the correct encoding in the servlet request (GB2312 for chinese characters)
    request.getParameter(xxx) yields ???
    new String(request.getParameter(xxx).getBytes("GB2312")) yields three boxes (values 20309, 27946 and 23380)
    new String(request.getParameter(xxx).getBytes("GB2312"), "UTF-8") yields nothing
    Any ideas?

  • How Do I Display HTML Formatted Text From A Data Table In Crystal Reports?

    I'm creating reports in Crystal XI.  The information being displayed in the reports comes from data tables where the text is formatted in HTML.
    I've worked with Crystal Reports enough to know that HTML text pulled from a data table doesn't appear in Crystal the same way it does in a web browser.  Crystal Reports ignores all the tags (...unless I'm missing something...) and just displays the text.
    Someone far more Crystal savy than I (...who I don't have access to...) came up with a Formula Field workaround that tricks Crystal Reports into displaying some basic HTML tags.  Here's that workaround:
    <!--
    stringVar TableName := ;
    TableName := Replace (TableName, "<ul>","<br> <br>");
    TableName := Replace (TableName, "<li>", "<br>   &bull; ");
    TableName := Replace (TableName, "</li>", "");
    TableName := Replace (TableName, "</ul>","<br> <br>");
    TableName := Replace (TableName, "<a", "<u><font color='blue'");
    TableName := Replace (TableName, "</a>", "</font></u>");
    TableName
    -->
    QUESTION - Does any similar workaround exist so I can display an HTML Table in Crystal Reports?  If not, is there any way to display HTML formatted text from a data table in Crystal Reports as it would appear in a web browser?

    Hi Steven,
    To display html text in Crystal Reports follows these steps.
    1. Right click on the field and select Paragraph tab.
    2. Under 'Text Interpretation' select 'HTML Text' and click OK.
    I have tried using the way,but it never works.So reply me if there is any way to solve the issue

  • I use classical Hebrew for my work, and Pages will only display English characters even with a Hebrew font selected. If I cut and paste Hebrew characters from another document, as long as the font is supported, it will appear in Pages.  If I type it won't

    I use classical Hebrew for my work, and Pages will only display English characters even with a Hebrew font selected. If I cut and paste Hebrew characters from another document, as long as the font is supported, it will appear in Pages.  If I type it won't continue in Hebrew.  I have tried downloading several fonts, including those from professional societies, but the only way to get Hebrew in my document is to cut and paste.  Does anyone know how to fix this?  I use an older MacBook running OS 10.9.1.  I used to do my Hebrew work in Word, but it is no longer supported by Mac OS.

    Just clarifying:
    Pages '09 has bad support for Hebrew, Arabic etc but will accept pasted text.
    Pages 5 has much better support but with bugs.
    If you have columns they are in the wrong order ie Text starts in the left column and ends in the right column.
    If you type English into Hebrew text it tends to fall in the wrong position eg instead of to the left of Hebrew punctuation it goes to the right.
    As Tom recommends the only real solution on the Mac is Mellel.
    Peter
    btw Tell Apple, they are amazingly slow to fix this running sore which has been broken since RtoL was supposedly introduced in OSX 10.2.3 over a decade ago.
    Peter

  • Unable to pick unicode characters from input file using "outside in"

    Hi,
    I am using your product "Outside in" to read unicode text from input
    source file. For reading text I am using TReadFirst and TReadNext even
    though "It is not picking unicode characters from input source file
    and also it is giving zunk character to the buffer". How can I
    retrieve unicode character from input source using "outside in"
    product. Your help makes me learn more stuff.
    Regards,
    Naresh.D

    I am trying to use CAReadFirst and CAReadNext to read unicode characters. Even it is not picking, I think is there any flags we need to set. can any one help to this.

  • Escaping characters on help page

    I would like to escape some html-code I'm placing on a help region. Is that possible? How is the escaping for escaped html region implemented? Can I use the same API?

    No, that does not help. I want it to show up in the webpage. So I want to be able to write some htmlcode on the page and display the actual html code for the reader. The comment would just make it not interpreted by the browser, but it would not show up on the webpage.
    In this case it is a basic DIV I want to show including the tags. I want to grab the code from it's actual place and show it here, so just reqriting the tags is not a good option. Calling a function to do some basic replacements would be OK though. Even better would be to be able to use an HTML region that escapes the special characters, but it seem like the help region only uses a standard html region.

  • Regarding displaying unicode

    Hello javaGurus!
    <Please Help me regarding displaying unicode>
    I am new to javaInternationalization,
    Till now i studies. Java Internationalization tutorial at http://java.sun.com/docs/books/tutorial/i18n/index.html and understand basic Structure.
    I have some problem displaying the unicode characters, such at, Arabic, and japneese.
    - How to display unicodes in applet?
    - How can we set the the Japneese, English, Arabic fonts in one application, which run on windows environment.
    - From where i can get the font s?
    Regards,
    waseem

    If you specify a String object with the unicode sequences (of the form "\u####\u####"), you can simply display it with the method setText(String) of the class javax.text.JTextComponent (or javax.JTextArea), for example. If you specify a String object with your own encoding in your source code, you can compile it with the command:
    javac -encoding <encodingName> fileName
    On Windows OS, the font ArialUnicodeMS will display almost all characters you are to show.
    You can find downloadable fonts in almost any search engine.
    - The following can be additional material for studying.
    http://java.sun.com/j2se/1.4/docs/guide/intl/fontprop.html
    http://developer.java.sun.com/developer/qow/archive/65/index.html

Maybe you are looking for

  • Best Practise for CRM

    Hi, I have installed BP for CRM and doing config for SAP CRM Standalone Integration. I have selected all scenarios in the scope including interactive reporting. Our main focus is interactive reporting which needs another client in same CRM system. I

  • Does anyone know how to authorise a computer in itunes please

    does anyone know how to authorise a computer to my itune account im not having much luck  thanks

  • Force shutting down

    A couple times so far, my computer has simply run out of ram and completely froze. I open up force quit and quit a few programs but then it gets a pinwheel of death. I wait for like 5 mins and then I hold the power button for a few seconds so it forc

  • ESB Call to BPEL contains the Version of BPEL Process

    Hi, I'm creating a ESB Routing Service to call a BPEL Process. Although I do not pout the version of the BPEL process on the WSDL that i give to the ESB Routing Service it always call the version to what it was developed, even thought i created a new

  • Wifi sync turn on feature no showing up on itunes.  Anyone know what's wrong

    I am trying to use wifi sync and I can't find the button to turn it on in itunes.  It is like it doesn't exist.