Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Java Servlet localization

servlet

  • Please log in to reply
5 replies to this topic

#1 nigus

nigus

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 21 December 2010 - 10:21 PM

I am developing a web based application using Java sevlet , HTML and Oracle 10g. I have a form that is developed by HTML which used to accept user input. The input is not English language text but it an other language(Amharic). Using my servlet code , I accept the input from the HTML form and I store it in to the oracle 10g database. What the problem here is the data stored in to the database is the numeric representation of the Unicode. but I don't want to store the numeric representation of the Unicode because when I retrieve it the system displays as it is.

Please If you have any idea how can I solve it ,let me know it quick.

Thanks
Nigus
  • 0

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 22 December 2010 - 12:55 AM

I believe that putting \u in front of a unicode string will transform it to the original text.
  • 0

#3 nigus

nigus

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 22 December 2010 - 03:42 AM

Thank you for your quick response but putting \u in front of the numeric representation of the Unicode doesn't change to its original text.
For example , " ገቢን በአግባቡ መ " is the numeric representation of the Unicode. I put \u in front of the text but there is no change.

Check it please and tell if it works for you.
  • 0

#4 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 22 December 2010 - 03:54 AM

That is no unicode: ገቢን በአግባቡ መ
Maybe it's processed by the browser, try putting it in [ code][/code ] tags
  • 0

#5 nigus

nigus

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 23 December 2010 - 03:59 AM

The Unicode is
+4872;+4706;+4757; +4704;+4768;+4877+4707;+4705; +4632;
.To get the exact Unicode please replace the "+" sign with "&#" . ገቢን በአግባቡ መ is the equivalent representation of the above Unicode.

Edited by nigus, 23 December 2010 - 04:11 AM.
Unicode

  • 0

#6 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 23 December 2010 - 07:41 AM

Could you try this?
   public static void main(String[] args){
        String unicodeString = "+4872;+4706;+4757; +4704;+4768;+4877;+4707;+4705; +4632;";
        String resultString ="";

        for(String part : unicodeString.split(";")){
            if(part.startsWith(" ")){
                resultString += " ";
                part = part.trim();
            }
            int number = Integer.parseInt(part.substring(2),16);
            char character = (char) number;
            resultString += character;
        }
        System.out.println(resultString);
        JOptionPane.showConfirmDialog(null, resultString);
    }
With &# instead of the + ofcourse.
I can't be sure if this works cause my computer just shows the white squares of "unknown character"... i could see the characters on my laptop tho.

If the strings get really long you may want to consider using a StringBuilder instead of the resultString for performance reasons.
  • 0





Also tagged with one or more of these keywords: servlet

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download