On 3/29/07, Kulvinder Singh <[EMAIL PROTECTED]> wrote:
>
> Hi Kyle,
>
> Thanks for the reply.
>
> I think i need to convert the string into Byte array in UTF8 Encoding,
> remove the unwanted bytes, convert that back to string and the HMTL Encode
> it.
>
This is mostly right, but you want to do XML entity escaping, not HTML
encoding. The rules have some similarities (less-than and greater-than
escaped syntax are the same) but also some differences (html escaping
doesn't require that apostrophe or quotation characters to be escaped).
See my previous message for the details on XML escaping.
-- Kyle
Please tell me if i am wrong.
>
> *Kyle Marvin <[EMAIL PROTECTED]>* wrote:
>
> On 3/29/07, Kulvinder Singh <[EMAIL PROTECTED]> wrote:
> >
> > Hi Kyle,
> >
> > Thanks thanks thanks for your prompt reply. I got it.
> >
> > The reason why i just cant let the "Content" sent to Google straight
> > away is that in some of my Outlook Calendar events, there were Printer Feed
> > characters like PageBreaks and the Google Server is not able to handle them.
> > Thats why i was getting GoogleServer Errors for Unicode 0xc characters.
> > Also, & and < are not supported by Google server. So i need to HTMLEncode
> > them.
> >
> > Consider a situation where in the Content for a Google Event contains a
> > PageBreak, & and < (all three of them). In that case, the kind of error i am
> > getting is :
> >
> > org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xc)
> > was found in the element content of the document.
> > org.xml.sax.SAXParseException: The content of elements must consist of
> > well-formed character data or markup.
> >
> > org.xml.sax.SAXParseException: The entity name must immediately follow
> > the '&' in the entity reference.
> >
> > Please tell me how to handle a event content containing PageBreak, & and
> > < characters which Google cant handle.
> >
>
> OK, I see. There's really two separate things I'd recommend:
>
> - I'd recommend you filter out the control characters (like PageBreak) out
> of the content. You can do this by looking for characters in certain
> ranges (ex. 0-31 are control chars in most character sets)
>
> - Because you are generating XML, you need to _XML escape_ characters that
> have special meaning in XML documents. Here's the characters to look out
> for and the encoded equivalents:
>
> less than (<) : <
> greater than (>) : >
> ampersand (&) : &
> apostrophe (') : '
> quotation (") : "
>
> Hope this helps,
>
> -- Kyle
>
> Thanks in advance.
> >
> > *Kyle Marvin < [EMAIL PROTECTED]>* wrote:
> >
> > On 3/28/07, Kulvinder Singh <[EMAIL PROTECTED] > wrote:
> > >
> > > Hi Kyle,
> > >
> > > Thanks a lot for your reply. Please help me furthur in this.
> > >
> > > I want to insert an Event in Google Calendar with Description/Content
> > > as "æ ¾æ¬çå ¸ &&&&". Now, how should i decide whether this is an HTML
> > > or
> > > text programmatically?
> > >
> >
> > If you aren't using any HTML formatting in the content (as in the
> > example string) , then I'd recommend just using plain text content. If you
> > encode it as UTF-8 characters, you shouldn't have to worry about doing
> > anything else with the HTTP Content-Type header or XML encoding attribute.
> >
> > Should i set the "type" of Content element as "text/html" everytime and
> > > HTMLENCODE it by default or any other way ?
> > >
> >
> > See above. Just use "text" or leave it off since that is the default.
> >
> > *Kyle Marvin <[EMAIL PROTECTED]>* wrote:
> > >
> > > Hi Kulvinder,
> > >
> > > For data in the API, you should not HTML encode the input data unless
> > > the "type" attribute of the title and content is "html". If you haven't
> > > set type, the default value is "text", per the Atom syntax spec (RFC4287).
> > > The gd:where element attributes don't have a type and are always
> > > considered
> > > to be text.
> > >
> > > For GData to be able to properly interpret encoded characters in your
> > > data, you need to provide appropriate signals about the encoding. The
> > > character set encoding of data sent via the API is determined by one of
> > > two
> > > things: the value of the charset attribute of the HTTP Content-Type
> > > header
> > > or the value of the "encoding" attribute on the <xml> declaration. If
> > > both
> > > are present, the HTTP header is considered canonical. If neither is
> > > present, the default is "utf-8". See [1] for more details and some
> > > examples.
> > >
> > > Hope this is helpful,
> > >
> > > -- Kyle
> > >
> > > [1] - http://diveintomark.org/archives/2004/02/13/xml-media-types
> > >
> > > On 3/21/07, Kulvinder Singh < [EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I am facing some international characterization problem with Google
> > > > API.
> > > >
> > > > I created a Google Event with
> > > > Title = "Planeringsmöte för ansökan VR 20/3 kl 18.00 ca" and
> > > > Where = "Planeringsmöte för ansökan VR 20/3 kl 18.00 ca" and
> > > > Content = "Planeringsmöte för ansökan VR 20/3 kl 18.00 ca "
> > > >
> > > > I did an HTMLEncode on these values of Title, Where and Content
> > > > before inserting in Google
> > > >
> > > > Now the event is sucessfully created at Google but with a problem.
> > > > When i see the agenda or any Week/Month view etc. these characters are
> > > > being
> > > > rendered as :
> > > >
> > > > " Planeringsmöte för ansökan VR 20/3 kl 18.00 ca"
> > > >
> > > > but when i go to edit this event, the Title and Where seems
> > > > corrected to "Planeringsmöte för ansökan VR 20/3 kl 18.00 ca" but
> > > > whenever i switch to any other view i again see them Encoded.
> > > >
> > > > Please help
> > > > ------------------------------
> > > > The fish are biting.
> > > > Get more
> > > > visitors<http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50>on
> > > > your site using Yahoo!
> > > > Search Marketing.
> > > >
> > >
> > >
> > > ------------------------------
> > > Food
> > > fight?<http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396545367>Enjoy
> > > some healthy debate
> > > in the Yahoo! Answers Food & Drink
> > > Q&A.<http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396545367>
> > >
> > >
> >
> > ------------------------------
> > Now that's room service! Choose from over 150,000 hotels
> > in 45,000 destinations on Yahoo!
> > Travel<http://travel.yahoo.com/hotelsearchpage;_ylc=X3oDMTFtaTIzNXVjBF9TAzk3NDA3NTg5BF9zAzI3MTk0ODEEcG9zAzIEc2VjA21haWx0YWdsaW5lBHNsawNxMS0wNw--%0A>to
> > find your fit
> >
> >
>
> ------------------------------
> Finding fabulous fares is fun.
> Let Yahoo! FareChase search your favorite travel
> sites<http://farechase.yahoo.com/promo-generic-14795097;_ylc=X3oDMTFtNW45amVpBF9TAzk3NDA3NTg5BF9zAzI3MTk0ODEEcG9zAzEEc2VjA21haWx0YWdsaW5lBHNsawNxMS0wNw--%0A>to
> find flight and hotel bargains
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---