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
Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve
My Carrier: compny
Accepted Solution

How to display apostrophe (') symbols on blackberry map

Hi every one

 

 I am displaying multiple pin point on Blackberry map and adding the label and description for the pin point,

in that sentence I am putting apostrophe (') symbols (ex- today's) so after that map is not displaying.

 

Please help me how to display that.

 

Thanks.

Please use plain text.
Developer
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to display apostrophe (') symbols on blackberry map

try to escape it with \, maybe it is treated as a special char. Or try the unicode notation instead, \u...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve
My Carrier: compny

Re: How to display apostrophe (') symbols on blackberry map

Hi I checked with \ it is not working

 

 and how to use Unicode?

       actually the description string I am getting from web services and in that I am getting the word like(today's) so I have to pass it as pin point description, how to do?

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display apostrophe (') symbols on blackberry map

Can you give us a code snippet that demonstrates a failing case and a working case?  Obviously we don't need to data from the Server, just debug that process and create a test that has the data hard coded in. 

Please use plain text.
Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve
My Carrier: compny

Re: How to display apostrophe (') symbols on blackberry map

Hi Peter

 

 

Thanks for reply See this code is not working

 

 

for(int loca=0;loca<dealDetail1.locationcount;loca++)
             {

                 String centerLt=(String) dealDetail1.lattitude.elementAt(loca);
                 String centerLon=(String) dealDetail1.longitude.elementAt(loca);
                
                 double longitude=Double.parseDouble(centerLon);
                 longitude=longitude*100000;
                 double latitude=Double.parseDouble(centerLt);
                 latitude=latitude*100000;
                           
               doc +="<location x='"+(int)longitude+"' y='"+(int)latitude+"' label='title' description='Today's' zoom='10' />";
             }
        
             doc +="</lbs>";
            
             MapsArguments marg=new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT, doc);
     
             Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, marg);     

 

See Here

 

description='Today's'  -> not working

 

description='Today\'s' -> not working

 

description='Todays'  -> working

 

please help me what to do to work below code

 

description='Today's'

 

Thanks.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display apostrophe (') symbols on blackberry map

I am not familiar with this processing, but I strongly suspect your problem is related to XML handling of text strings.

 

You are in effect, passing in an XML document:

 

doc +="<location x='"+(int)longitude+"' y='"+(int)latitude+"' label='title' description='Today's' zoom='10' />";

 

The way this will look, when this code is actually executed, is that you will get a String like the following:

 

<location x='1234' y='3456' label='title' description='Today's' zoom='10' />

 

The problem is clear - the apostrophe in "Today's" is being used to delimit the description attribute, so now you have badly formed XML.  The XML parser can't figure out that the first apostrophe is not actually the end of the string that you want to use as the description. 

 

You have to change text that could confuse in XML in a similar way as you escape special characters when you code strings.  For a String, to get a double apostrophe in a String, you have to code

String stringWithDoubleApostrophe = "\"";

So the "\" is being used to tell the compiler that the following character should be treated as is and not processed.  . 

 

In XML, you use a different mechanism, and in this case you would replace the apostrophe with (from memory) "&quote;" (without the surrounding "). But the principle is the same.  By converting the single apostrophe to "&quote;" you are making sure that it is treated as part of the attribute and not processed. 

 

Anyway, here is not the appropriate place for an XML lesson.  Do some research yourself on this.  But the short answer to your problem is that you need to encode any text you use as an XML attribute, to make sure that the XML parser can process it correctly when it contains characters that are treated specially in XML parsing. 

Please use plain text.
Regular Contributor
paolorodriguez
Posts: 62
Registered: ‎11-27-2012
My Device: BlackBerry Bold 9900
My Carrier: GlaDOS

Re: How to display apostrophe (') symbols on blackberry map

[ Edited ]

You would have to use entities.

var = "... description='Today\'s' zoom=..." means that var contains:

... description='Today's' zoom=...

This naturally leads to malformed XML.

Do this instead:

var = "... description='Today&apos;s' zoom=..."

Like all my posts, and mark them as the solution if it solved your problem.


My Website: Paolo Rodriguez

Please use plain text.