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
Highlighted
Developer
Posts: 39
Registered: ‎04-01-2008
My Device: Not Specified
Accepted Solution

getDevicePhoneNumber() delivers phone number with unicode left-to-right mark


I am using getDevicePhoneNumber(boolean format) ( http://www.blackberry.com/developers/docs/4.6.0api/net/rim/blackberry/api/phone/Phone.html#getDevice...(boolean) ) to get my device's phone number. I know this might not be the actual number. I also cannot use anything else like the device pin. I use this to fill a "my phone number" field by default which can be edited manually in case the number is not correctly read from the SIM card.

It is actually working fine and shows the phone number in the field. However, a closer look to the string shows that it has the unicode mark "%E2%80%8E" in front of the string. This mark is known as unicode (utf-8) "LEFT-TO-RIGHT MARK" ( sources: http://www.tachyonsoft.com/uc0020.htm and http://unicode-search.net/unicode-namesearch.pl?term=mark ).

I only experienced this in BB OS 4.6 devices (didn't check 4.7 yet), but it seems not to occur in OS 4.5 and below.

Has there been any changes for the string orientation in OS 4.6?

Can I get rid of that mark by using String.trim(); or do I need to use something else?
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

Is it happening for both cases like "getDevicePhoneNumber(true)" an d"getDevicePhoneNumber(false)".

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 39
Registered: ‎04-01-2008
My Device: Not Specified

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

I didn't try to get the formatted number yet because I actually cannot work with that. I am using the unformatted (false) getter only.
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

Can you please list the devices you tested on. I tried on simulator 9000 and JDE 4.6 it works as desired.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 39
Registered: ‎04-01-2008
My Device: Not Specified

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

AFAIK this does only appear on a real Bold device. Didn't try the Storm yet because I don't have one Smiley Sad
BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

What version of handheld software are you running on the BlackBerry Bold?  You can find this under Options, About on the BlackBerry Smartphone.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 71
Registered: ‎03-10-2009
My Device: Not Specified

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

The same happens with Phone.getDisplayPhoneNumber (see http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=29411 ). This seems to be on OS 4.6 only and not below (4.5) or above (4.7). I only have a 4.5 device, so I've only seen this on the emulator.
New Developer
Posts: 3
Registered: ‎08-30-2009
My Device: Bold 9000 and Curve 8310

Re: getDevicePhoneNumber() delivers phone number with unicode left-to-right mark

This problem persists on my Bold 9000 but not any of my other GPS enabled phones.

 

Since it was a pain to try to figure out, here's the code I used to resolve this issue.

 

private String trimPhoneNumber(String phoneNumber){ byte phoneBytes[] = phoneNumber.getBytes(); int length = phoneNumber.length(); int offset = 0; if ( phoneBytes[0] == 0x3F ) { length--; offset++; } return new String(phoneBytes, offset, length); }