Windows Arabic Encoding Cp1256 &#XXX;

in this post I will address the Arabic encoding problems.

any one may face one or more of the following scenarios:

  1. Retrieving Arabic data from database and wanna display it in a web page correctly.­
  2. Getting encoded Arabic data from web page and reading it correctly.

for the first Scenario  Retrieving Arabic data from database and wanna display it in a web page correctly.

it may works great with you by just adding the following page Encoding to your jsp page
­

­<%@ page pageEncoding="windows-1256" %>

and if it didn't work you may need to do encode the retrieved Arabic String as follows:

 String value2 = new String(arabicString.getBytes(), "Cp1256");

and this will encode the Arabic letters as &#XXX;:

 for example "المستخدم" word will be translated to "&#1575;&#1604;&#1605;&#1587;&#1578;&#1582;&#1583;&#1605;" inside the HTML page.

for the second Scenario Getting encoded Arabic data from web page and reading it correctly.

you will need to manipulate the retrieved Arabic encoded serious ­"&#1575;&#1604;&#1605;&#1587;&#1578;&#1582;&#1583;&#1605;" as follows: 

 ­/**     
  * decode th­e passed value
  * @return the encoded arabic value
  * @param value
  */­
private String denodeToArabic(String value) {      
   if(value.indexOf("&#")==-1)
     return value;
      
   String newString ="";
   value = value.replaceAll("&#","");
   String[] characters = value.split(";");
   for(int i=0; i<characters.length; i++){
      if(characters[i].startsWith(" "))
         newString +=" ";
      else if(characters[i].trim().length()!=4)
         newString += characters[i].trim();
      else
         newString +=(char)Integer.valueOf(characters[i].trim()).intValue()+"";      ­
   }
      
   return newString;
}­­

 References:

  • ­
    http://download.oracle.com/docs/cd/B10500_01/server.920/a96529/appa.htm#958278
  • http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html

True wisdom can never find

True wisdom can never find fault or a person at fault. - Marla Ahlgrimm

I have not much time to

I have not much time to visit many websites. But today I found this site accidently. I explored much information which is useful to my life. Thanks! Jaya Liga  

Agen Sbobet

So,for the a lot of

So,for the a lot of http://www.jmpartnership.uk.com/slow.html part,aggregate we paid while application the millions involving for your just superior section accounts and aswell now we just absorb the money for money for what we'll get complex in return.Fake Cartier Watches that is included in best chic and authority are absolutely benign accumulating agencies that deserve to http://www.londonforum.org.uk/onload.php be captivated admitting an impressive.So you charge be actual accurate with the superior if you are traveling to buy one.People generally accept such a confounding that the added big-ticket the bigger quality.

naruto

Sebagai perkembangan zaman dan saat ini teknologi yang terus berkembang, Cantik itu sehat
banyak contoh modifikasi yang muncul dan kita dapat menemukan contoh modifikasi Blog Harga Motor Fz16 dari sumber-sumber
rujukan berbeda media massa serta sebagai online.baca blog kami
Manfaat dari kacang yang paling fenomenal dalam dunia
kesehatan adalah Selengkapnya baca di sini Perannya dalam membentuk jantung sehat.
pakai Blog Harga Mobil Sayuran ini menjadi salah satu jenis sayuran yang mudah kita temukan di
mana-mana, hampir setiap pedagang kuharga sayuran menjualnya. Banyak kuliner Indonesia
yang menggunakan kacang sebagai salah satu bahan yang digunakan.tentunnya www.bloghargahape.blogspot.com

Powered by Drupal - Design by artinet