Unicode help...

Hi,
Im having some problems with unicode and did all the necessary things shown below:
1. Add <%@page contentType="text/html" pageEncoding="UTF-8"%> to JSP
2. Set response.setContentType("text/xml;charset=UTF-8");
3. As im using httpUrlConnection to connect, i also add URIEncoding to my server.xml.
4. I also set unicodetStr = new String(str.getBytes("ISO-8859-1"),"UTF-8");
The problem is that when I entered chinese words in my JSP, the values become ??? and it it being store in my database. After I restart my tomcat, the chinese words are able to store correct(in chinese) in my database. When I try again the next day, the same data become ??? again. Does anyone know how can i solve this?
Im using tomcat 5.5.20 on linux and my database is orcacle.
Grace

You look at the filter :
package com.lin.ums.web;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class CharacterEncodingFilter implements Filter
private FilterConfig config;
public void init(FilterConfig config) throws ServletException
this.config = config;
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
String encoding = config.getInitParameter("encoding");
if(encoding == null)
encoding = "gbk";
request.setCharacterEncoding(encoding);
response.setCharacterEncoding(encoding);
chain.doFilter(request, response);
public void destroy()
Then you add in web.xml:
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>com.lin.ums.web.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Similar Messages

  • Converting byte[] to unicode , help needed.

    need help, folks.
    i need to convert byte[] to unicode in byte[] form
    say i already loaded bunch of data
    byte[] bytes = {........} //bunch array of bytesand i read in the bytes as a stream in the native form.
    ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
    InputStreamReader isr = new InputStreamReader(stream,"GB18030");how do i get the bytes back in unicode ? i've been trying all kinds of methods, but doesnt seems to get what i want. i'm novice programmer, someone pls guide me ? thx.

                String s ;
              StringBuffer buffer = new StringBuffer();
              try {
                   ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
                   InputStreamReader isr = new InputStreamReader(stream, "GB18030");
                   Reader in = new BufferedReader(isr);
                   int ch;
                   while ((ch = in.read()) > -1) {
                   buffer.append((char)ch);
                   in.close();
                   s = buffer.toString();
                   bytes = s.getBytes("UnicodeLittle");
                   out.write(bytes);
              } catch (IOException e) {
                   e.printStackTrace();
                   //return null;
              }ah, nvm, i found a better solution to it, i'm little confused before this. the code above works fine.
    well, thx alot.

  • Need Unicode Help Please

    I'm trying to print some Chinese characters using java based on its Unicode number, but when I run the Chinese.class file I always get: Exception in thread "main" java.lang.NoClassDefFoundError: Chinese. Can someone help me solve this? My code is below.
    public class Chinese
    public static void main (String[] args)
    System.out.println((char)4E03);
    Thanks,
    LBFF

    This is my CLASSPATH in the System Variables: "C:\Program Files\JavaSoft\JRE\1.3.0_01\lib\ext\QTJava.zip"
    But It give the same error in that subdirectory and every directories above that =(

  • Unicode help required in FormsCentral

    Hi I need to show the term CO2 - I have seen a discussion pointing to how to use unicode:
    http://help.adobe.com/en_US/formscentral/using/WSc306897c3ccf9e12-1880 e33e12d764edb1b-8000.html#WS7a7933fba9c1224d3841244012d76b32dbf-7ffe.
    But it doesn't show anything about how to use unicode. Can anyone help?
    Regards,
    Bill

    On Mac OS X you need to:
    Open your form in FormsCentral for editing
    Place the cursor in the field where you want the ₂ (note that this message is being typed on MacOS)
    Select menu item Edit-> Special Characters...
    In the search window that appears enter "2" (I had to scroll to the top of the window).
    In the list of 2s that appear, select the one that is subscript.  This should insert the character for you.

  • Unicode help please

    What is Alignment of structure in Unicode,
    and what is difference in aligned and non aligned unicode and NUS

    Hi
    See this
    The Link will be helpful to you.
    Re: Upgrade 4.6 to ECC - What are the responsibilites
    regarding Unicode influence in Standard programs
    Very good document:
    http://www.doag.org/pub/docs/sig/sap/2004-03/Buhlinger_Maxi_Version.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d37d1ad9-0b01-0010-ed9f-bc3222312dd8
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/589d18d9-0b01-0010-ac8a-8a22852061a2
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f8e316d9-0b01-0010-8e95-829a58c1511a
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Role of unicodes in upgrades.

    Dear members,
    Please explain me the role of unicode in upgradation.
    Regards,
    Niraj.
    Edited by: Neerajpatro on May 30, 2009 3:45 PM

    What is Unicode?
    In non-Unicode system, each character is represented with 8 bit code. Unicode provides a unique number for every character independent of platform, program, and language.
    Unicode is a 16-bit code to represent universal character set, which is used to facilitate a better exchange of data between different systems.
    E.g.: problems that may arise when communicating systems use different code pages. These problems mainly arise, because a code page is only applicable to specific languages and cannot be combined at with other code pages. Using Unicode helps you avoid these problems.
    Unicode Compliance
    Transaction UCCHECK
    The transaction UCCHECK is used to find Unicode related issues. You can use transaction UCCHECK to examine a Unicode program set for syntax errors without having to set the program attribute "Unicode checks active" for every individual program. From the list of Unicode syntax errors, you can go directly to the affected programs and remove the errors. It is also possible to automatically create transport requests and set the Unicode program attribute for a program set.

  • Can someone help me understand how ePub CSS @fontface Unicode characters are supported in td , but not in div or other elements?

    Hi,
    I'm working on a project to convert several hundred thousand life sciences articles into epub format, and we have run in to a problem with character entities.
    Being that these are scientific articles, the characters are from a wide range of Unicode charts, and are essential to transmitting the meaning of the data.
    The problem is that in my epub, the character entity inside a table data cell is rendering the @font-face correctly, but inside any other HTML element, the character renders as an empty box on our ipad2s.
    I've placed pre tags in hopes that the unicode will not be rendered in your browser here. The code point in this example is x1d542 just in case.
    So inside div, we see boxes, inside td, we see the character rendered properly.
    <pre>
          <div class="stix">Let &#x1d542; be a field, which will be either the complex numbers &#x02102; or the finite field &#x1d53d;</div>
          <table id="t31" rules="all">
            <tr>
              <td>&#x1d542;</td>
              <td class="stix">&#x1d542;</td>
              <td>U+1D542 MATHEMATICAL DOUBLE-STRUCK CAPITAL K </td>
            </tr>
    </pre>
    My CSS looks like this:
    <pre>
    @font-face {
        font-family: 'STIX';
        src: url('STIX-Regular.otf') format('opentype');
        font-weight: normal;
        font-style: normal;
        unicode-range:  U+02B0-02FF, U+07C0-07FF,  U+0900-097F,U+0F00-0FD8, U+1D00-1D7F, U+1D80-1DBF, U+1D400-1D7FF, U+1E00-1EFF, U+1F00-1FFE,U+2000-206F, U+20A0-20B8, U+20D0-20F0, U+2300,23FF, U+25A0-25FF, U+2600-26FF, U+27C0-27EF, U+27F0-27FF, U+2900-297F, U+2A00-2AFF, U+2B00-2B59, U+2C60-2C7F ;
    @font-face {
        font-family: 'STIX-Math';
        src: url('STIXMath-Regular.otf') format('opentype');
        font-weight: normal;
        font-style: normal;
        unicode-range:  U+02B0-02FF, U+07C0-07FF,  U+0900-097F,U+0F00-0FD8, U+1D00-1D7F, U+1D80-1DBF, U+1D400-1D7FF, U+1E00-1EFF, U+1F00-1FFE,U+2000-206F, U+20A0-20B8, U+20D0-20F0, U+2300,23FF, U+25A0-25FF, U+2600-26FF, U+27C0-27EF, U+27F0-27FF, U+2900-297F, U+2A00-2AFF, U+2B00-2B59, U+2C60-2C7F ;
    .stix   {
            font-family: "STIX", "STIX-Math", sans-serif;
    </pre>
    Is it possible that this is a rendering bug, because the character is rendering in the table cell, but not in other elements?
    Have I missed something obvious?
    Thanks,
    Abe

    I assume you are including the STIX font as part of your epub files?     
    Perhaps the folks who do this blog might be able to help -- they have done some work with font embedding:
    http://www.pigsgourdsandwikis.com/2011/04/embedding-fonts-in-epub-ipad-iphone-an d.html

  • I have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

    i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

    i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

  • Unicode and ascii conversion help needed

    I am trying to read passwords from a foxpro .dbf. The encrpytion of the password is crude, it takes the ascii value of each char entered and adds an integer value to it, then stores the complete password to the table. So to decode, just subtract same integer value from each chars retieved from .dbf. pretty simple.
    The problem is that java chars and strings are unicode, so when my java applet retrieves these ascii values from the .dbf they are treated as unicode chars, if the ascii value is over 127 I have problems.
    The question. how can i retrieve these ascii values as ascii values in java?
    Should I use an InputStream like:
    InputStream is=rs.getAsciiStream("password");
    Is there a way to convert from unicode to extended ascii?
    Some examples would be helpful, Thanks in advance.

    version 1
    import java.nio.charset.Charset;
    import java.nio.ByteBuffer;
    import java.nio.CharBuffer;
    class Test {
        static char[] asciiToChar(byte[] b) {
            Charset cs = Charset.forName("ASCII");
            ByteBuffer bbuf = ByteBuffer.wrap(b);
            CharBuffer cbuf = cs.decode(bbuf);
            return cbuf.array();
        static byte[] charToAscii(char[] c) {
            Charset cs = Charset.forName("ASCII");
            CharBuffer cbuf = CharBuffer.wrap(c);
            ByteBuffer bbuf = cs.encode(cbuf);
            return bbuf.array();
    }version 2
    import java.io.*;
    import java.nio.charset.Charset;
    class Test {
        static char[] asciiToChar(byte[] b) throws IOException {
            Charset cs = Charset.forName("ASCII");
            ByteArrayInputStream bis = new ByteArrayInputStream(b);
            InputStreamReader isr = new InputStreamReader(bis, cs);
            char[] c = new char[b.length];
            isr.read(c, 0, c.length);
            return c;
        static byte[] charToAscii(char[] c) throws IOException {
            Charset cs = Charset.forName("ASCII");
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            OutputStreamWriter osw = new OutputStreamWriter(bos, cs);
            osw.write(c, 0, c.length);
            osw.flush();
            byte[] b = bos.toByteArray();
            return b;
    }

  • Need help with Tamil unicode fonts in Macbook OSX 10.6.7

    I am really desperate for some help figuring out my Tamil unicode font problem. With great difficulty I got all these fonts set up on my previous ibook G4. When that computer died in the fall I got this new Macbook, and had all my data brought from the old computer to the new one. Fonts were working great, as before. Well recently I had a hard drive failure on my new Macbook (OSX 10.6.7). I now have a new hard drive, and I brought over all my data from an external hard drive using Time Machine. Everything appeared to be working great....except the Tamil fonts. Previously I was using Murasu Anjal unicode font which allowed me to type in Tamil font and view Tamil on webpages, no problem. I understand that Snow Leopard has Tamil font support (including Anjal), so I am confused as to why they were working before but are not working now-especially because on my husband's Macbook Pro (OSX 10.6.5) you can see Tamil fonts on webpages and he has no special Tamil font installed whatsoever. For me the only thing visible is boxes. I am in the midst of finishing up a dissertation which is really dependent on being able to read and write in Tamil fonts. I am desperate to get this fixed but just cannot seem to figure it out. I would greatly appreciate any help or advice!!! Thanks so much!!!

    I've always used the Anjal keyboard with no problem...at least there was no problem before my MacBook hard drive had to be replaced, with a newer operating system, as I had mentioned previously. When I type in Pages, NeoOffice or TextEdit, the results are the same. Many of the characters show up, but vowel combinations--especially the "o" or "u" vowels--show up incorrectly or are unintelligible. Strangely, typing in Tamil font (using Anjal keyboard) in internet searches works perfectly, but ONLY in Firefox (?) NOT in the Safari browser. Prior to re-installing the InaiMathi font, which had seemingly vanished with the transfer of my data to the new hard drive, I was unable to type Tamil anywhere, not even in Firefox. Now it works only in Firefox. For example, if I were to type in Tamil in this window, it works fine: தமிழ் நாடு. 
    Being able to do Tamil searches in Firefox as I had previously is really a major boon for me, but of course I'd love to be able to produce Tamil text, especially as I am about to embark on a 6 month research jaunt to South Asia.
    Many thanks for all your help thus far, and for any further advice you might have.

  • [HELP!] perl and unicode are not working

    I have a database that I know supports Unicode, I'm trying to read/write data using perl and I'm pulling my hair out! I have a table populated with some Unicode characters that I inserted using TOAD and this sql statement:
    insert into jay_test values (-101, 'Τη γλώσσα μου έδωσ');
    When I look at the data in TOAD everything looks great, when I read the data out using .NET it works great, when I read it out using PERL the result if a bunch of question marks.
    Here is the code:
    #!/usr/bin/perl -w
    <%
    use utf8;
    use DBD::Oracle;
    $Response->AddHeader("Content-Type","text/html; charset=utf-8;");
    my $dbh2 = DBI->connect($db, $user, $password, {AutoCommit => 1});
    my $x = $dbh2->ora_can_unicode();
    my $sth = $dbh2->prepare("SELECT i, j from jay_test order by i desc");
    $sth->execute();
    while (my ($i, $j) = $sth->fetchrow_array()) {
         debug("i = $i, j = $j");
         $html .= qq{
              <tr>
                   <td>$i</td>
                   <td>$j</td>
              </tr>
    The result is this:
    -101      ?? ?????? ??? ????
    As a note: the line "$dbh2->ora_can_unicode();" returns a value of 3, which means that Unicode should be fully supported.
    Anyone who can point me in the right direction will be my savior! Thanks in advance

    The OS is Red Hat Enterprise Linux Server release 5.4 (Tikanga)
    The Kernel is 2.6.18
    Database is 10g
    Toad is 10.1.1.8
    Here are the parameters that PERL is seeing:
    my $params = $dbh2->ora_nls_parameters();
    print_r($params); return;
    [Hash] {
         NLS_CALENDAR => GREGORIAN
         NLS_CHARACTERSET => AL32UTF8
         NLS_COMP => BINARY
         NLS_CURRENCY => $
         NLS_DATE_FORMAT => DD-MON-RR
         NLS_DATE_LANGUAGE => AMERICAN
         NLS_DUAL_CURRENCY => $
         NLS_ISO_CURRENCY => AMERICA
         NLS_LANGUAGE => AMERICAN
         NLS_LENGTH_SEMANTICS => BYTE
         NLS_NCHAR_CHARACTERSET => AL16UTF16
         NLS_NCHAR_CONV_EXCP => FALSE
         NLS_NUMERIC_CHARACTERS => .,
         NLS_SORT => BINARY
         NLS_TERRITORY => AMERICA
         NLS_TIMESTAMP_FORMAT => DD-MON-RR HH.MI.SSXFF AM
         NLS_TIMESTAMP_TZ_FORMAT => DD-MON-RR HH.MI.SSXFF AM TZR
         NLS_TIME_FORMAT => HH.MI.SSXFF AM
         NLS_TIME_TZ_FORMAT => HH.MI.SSXFF AM TZR
    Do i need to issue a PERL command to change one of these NLS params?
    I appreciate the help everyone, this issue is killing me!

  • ** Plz help me in displaying unicode character **

    Hi,
    I hava a problem with the following code. Actually I want to display some arabic character with the help of unicode. Plz go through the following code.
    import java.awt.*;
    class Unicode extends Frame
    public static void main(String args[])
    Frame f = new Frame("Unicode");
    f.setSize(200,200);
    String str="\u0600";
    TextField tf=new TextField(str);
    f.add(tf);
    f.setVisible(true);
    I m trying to print that character on a textfield. However, this is not the requirement but for only testig purpose. I get the character '?' in the resulting textfield. plz tell me that how can I use unicode to print other languages character anywhere like on awt, swing or in html. plz reply soon . Thanks
    Fahad Ahmed

    \u0600 is an unassigned Unicode character, so there's no way to do that. However I assume you mean you want to display Arabic characters such as \u0627, Arabic Letter Alef (&#x0627). Then you need to find a font that can render those characters properly, and assign that font to the TextField using its setFont() method.
    I notice you are using AWT, which probably means you are trying to do this in an applet. If that's the case then "find a font and use it" is going to be a big problem, because you don't know what fonts your clients' computers have available.

  • Please help Unicode!!! thanks

    Hi all!
    I copied two files from java.sun.com and run it.
    But the program didn't show the Font correctly(Unicode).
    I've been told by the instruction of how to run this program is:
    I have to do something like"Before trying it out, verify that the appropriate fonts have been installed on your system. If you are using the JDK software that is compatible with version 1.1, make a copy of the font.properties file and then replace it with the font.properties.ja file."
    but I dont know how to do this. I dont know where are those files
    to copy and replace.
    Does expert out there can help me ?
    Please!! please! please!! thanks a lots!!!

    This chapter in the tutorial has some information which you may find of great use - particularly the "Character and Byte Streams" section.
    http://java.sun.com/docs/books/tutorial/i18n/text/convertintro.html

  • [HELP] Problem when update 1 unicode form

    hi all,
    I got a problem when I update unicode form :(
    so, I have already tested my web application (Struts-ibatis-velocity-tiles) on my PC (tomcat 5.5.12, mysql 4.1 - utf8 default, JDK 5.0), everything was okie. I could update 1 unicode form (the form which contains unicode characters - firstname, lastname). I use 1 filter for output and input, below is my web.xml:
    <!-- Filter to set character encoding on each request -->
    <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>filters.SetCharacterEncodingFilter</filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
    </init-param>
    </filter>
    <!-- Define filter mappings for the defined filters -->
    <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <servlet-name>action</servlet-name>
    </filter-mapping>
    <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <servlet-name>velocity</servlet-name>
    </filter-mapping>
    but ... when I deploy and run it on eatj.com, mysql4.1 - utf8, jdk 5.0, I couldn't update unicode form, my last name and first name fields couldn't be saved with unicode characters (utf-8) ...
    what happened :( ... Is this problem of hosting or my web application ??? :(
    help me :(
    thanks in advance,
    bowlkhin

    You need to install the bc package. Apparently the script uses bc to calculate some integer values.
    Brian

  • I am trying to install Adobe Premiere Elements 9 without success. I successfully installed Photoshop Elements 9 without a problem. The message I am getting is 'Invalid Unicode file - .\Autoplay\LangData\en_US\lang.dat'. Anyone out there who can help pleas

    I am trying to install Adobe Premiere Elements 9 without success. I successfully installed Photoshop Elements 9 without a problem. The message I am getting is 'Invalid Unicode file - .\Autoplay\LangData\en_US\lang.dat'. Anyone out there who can help please?

    click setup, not autoplay.

Maybe you are looking for

  • BAPI for Maintain Scheduling line agreement

    Dear ABAPer, I am using SAP version ECC 5.0. I want to develop Change Scheduling line agreement  enhancement. my requirement is, any BAPI is there for the same. if you have any idea, please help me. thanx. with best regards, Velmurugan.S

  • Error message I need while creating PO

    Dear Experts. I need to set error message when we try to convert deleted purchase requisation into Purcahse order. Pls can any one help how to set. Thanks in advance, With Rgds, Vinod

  • I fullfilled my 2 years contract and how do I get my iphone 4 unlocked

    Do I contact Apple or my service provider?

  • XI Proof of Concept

    Hi Xi Sappers, I am new to the XI world. I was looking for some documentation on how to conduct a POC (Proof of Concept) for XI. Basically it should encompass a sample landscape, most common business scenarios, ways to test thruput, error messaging,

  • Placing DCS2.0 in illustrator

    I created a photoshop document as multichannel with spot colors and I want to place this into illustrator.. cs3. I get "DCS eps can not be opened or embedded please place this file using the link option"... what did I do wrong, this is supposed to wo