Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 134
Registered: ‎05-31-2010
My Device: 8300
Accepted Solution

arabic language support for app dev

Hi All,


I'm doing an app which is having arabic language support.The problem is ,i am not able to get the data from the edit field as arabic though i'm able to enter data in arabic.It is showing like(?????).I tried in a lot of methods like:

String arabicString=new String(arabicEditField.getText().getBytes(),"UTF-8");

String arabicString=new String(arabicEditField.getText().getBytes("UTF-8"),"UTF-8");

String arabicString=new String(arabicEditField.getText().getBytes("ISO-8859-1"),"ISO-8859-1");

String arabicString=new String(arabicEditField.getText());

The app is able to take the arabic value directly like

String arabicString="التسجيل";

but the problem is occuring(?????) when reading the text from edit field and storing that value in String.

So,Please help me out.Thanks in advance.


Thanks&regards,
Sree Harsha.P

Trusted Contributor
Posts: 134
Registered: ‎05-31-2010
My Device: 8300

Re: arabic language support for app dev

heelllo,

 

 

any body reply plzz....Its the urgent requirement for my proj......

 

thanks,

sree harsha.p

Developer
Developer
Posts: 137
Registered: ‎06-01-2009
My Device: Not Specified

Re: arabic language support for app dev

I have similar issue with French char input and not sure what to do about it.

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: arabic language support for app dev

Woops, try not to make the same post in different areas of the forum. Put it in the area that it is related to, in this case the developer area.

 

I made a post to your problem but didn't realize it was in the App World section.

 

http://supportforums.blackberry.com/t5/BlackBerry-App-World-Development/arabic-lang-support-for-app-...

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Arabic language support for app dev

I'm a little confused here.

 

Assume arabicEditField is a BasicEditField.  Then it maintains, itself, a String that represents it state.  If you do a getText(), then you are going to get a reference to that String.  This String should be the contents of the Field, so you should only need to do:

 

String arabicString=arabicEditField.getText();

 

Having got this, playing round with the encoding to convert to bytes and then back seems completely redundant.

 

I would use the debugger, and having put some Arabic characters into a Field, and having it display correctly, I would chase down the internal fields involved and see where the conversion goes wrong. 

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Arabic language support for app dev

I caught that too but was not sure so I did the conversions anyway.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Arabic language support for app dev

Actually what I'm suggesting might not even work, but I'd be interested to find out.  I'm not sure how you can run non English in a Simulator.  Any ideas?

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Arabic language support for app dev

Just get what you know to be non-Latin chars on the simulator (convert to bytes and copy into simulator, convert to chars and copy into simulator, find something on the simulator's browser [I have been using http://موقع.وزارة-الاتصالات.مصر/ar/default.aspx] and copy it). I'm pretty sure it is supported since all BlackBerry's support UTF-8 and UTF-16BE.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Arabic language support for app dev

Ok I finally got to the simulator, I wrote a quick couple lines of code:

char[] ch = new char[]{(char)1575, (char)1604, (char)1578, (char)1587, (char)1580, (char)1610, (char)1604};
String str = new String(ch);
Clipboard.getClipboard().put(str);

edit = new BasicEditField();
add(edit);
edit.setChangeListener(new FieldChangeListener() {
	
	public void fieldChanged(Field field, int context)
	{
		String data = edit.getText();
		try
		{
			byte[] utf = data.getBytes("UTF-8");
			byte[] unicode = data.getBytes("UTF-16BE");
			byte[] iso = data.getBytes("ISO-8859-1");
			byte[] defaultC = data.getBytes();
			int len = iso.length;
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
});

where "ch" is one of the example that the original poster used. The string created was properly formated (right-to-left representation), no problems adding to Clipboard. Pasted it into the BasicEditField (visually the field switches to the right so it is formated correctly), the returned string is good. I converted to bytes (UTF-8,. UTF-16BE, ISO-8859-1, and the default encoding). Then using .Net I converted them back to a string and as I tested previously UTF-8 and UTF-16BE work fine and come out correct, ISO-8859-1 and default encoding do not.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Trusted Contributor
Posts: 134
Registered: ‎05-31-2010
My Device: 8300

Re: Arabic language support for app dev

Hi,

 

    I dont know where to post ....so i posted in two threads...sorry..

 

I used BasicEditField and "UTF-16BE" as encoding technique.I'm not getting the text from the BasicEditField as arabic,while converting into basicEditField.getText() the text is modified as ?????.And the encoding technique "UTF-16BE" is not working for english text also.if i change the project or eclipse encoding to "UTF-16BE " the entire code is displaying in a single like

 

000000000000000000000000000000000 000000000000000000000000

 

Please help me out.

 

 

Thanks & regards,

Sree Harsha.P