A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
How to convert arabic into UCS hexadecimal code?
Murtaza Lokhandwala
Ranch Hand
Joined: Jan 28, 2010
Posts: 35
posted
May 08, 2011 04:07:49
0
I have a code like this-
public class ArabToHex { public static String stringToHex(String pData) { StringBuffer encodedData = new StringBuffer(); StringBuffer sBuff = new StringBuffer(pData); for (int i = 0; i < sBuff.length(); i++) { char ch = sBuff.charAt(i); int chVal = (int)ch; // if this is a special character (ie. > 8 bits), encode it if (chVal > Byte.MAX_VALUE) { encodedData.append("").append(Integer.toHexString(chVal)).append(";"); } else { encodedData.append(ch); } } return encodedData.toString(); } public String getHex(String s) { return stringToHex(s); } }
It works when i terminate the append("") but when i work as it is by inputting an arabic word, it gives some undefine result ..
i need result like this- "ﺮ" "ﻌ" etc
moderator edit: added code tags
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
I like...
posted
May 08, 2011 06:04:05
1
Murtaza,
I have added code tags to your code, to make it more readable, and moved your topic to our "Java in General" forum.
OCUP UML fundamental
ITIL foundation
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: How to convert arabic into UCS hexadecimal code?
Similar Threads
parsing data and storing in the xml
code to handle arabic shaping text
Generic type casting
Unicode parsing exception
Convert a String into a Regular Expression
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter