That's odd.  I pasted my XML from 
http://www.planyourdive.com/google_api_problem.xml
into the validator at http://www.w3schools.com/Dom/dom_validate.asp,
and it reported no errors.

I was hoping that by constructing the request using a .NET XmlDocument
(as opposed to, say, string concatenation), that .NET would take care
of encoding the offending characters.  By simply specifying the
encoding when writing to the HttpWebRequest, my immediate problem
appears to have been solved:

using (StreamWriter sw = new StreamWriter(req.GetRequestStream(),
Encoding.UTF8))
{
  sw.Write(data.OuterXml);
  sw.Flush();
  sw.Close();
}

It's my understanding that UTF8 is the default encoding in .NET, so I
wouldn't have thought this would make any difference.

On Feb 26, 2:57 am, Frank Mantek <[email protected]> wrote:
> This is always tricky and depends heavily on what you are actually  
> sending over the wire. If i take your xml url to the w3c validator, i  
> get:
>
> "Sorry, I am unable to validate this document because on line 7 it  
> contained one or more bytes that I cannot interpret as us-ascii (in  
> other words, the bytes found are not valid values in the specified  
> Character Encoding). Please check both the content of the file and the  
> character encoding indication.
> The error was: ascii "\xC3" does not map to Unicode"
>
> As this indicates, there is an http charset indicator, and this one  
> rules supreme on the web. it matters more than the declaration inside  
> the document, for pretty obvious reasons. So maybe you are creating a  
> conflict right there.
>
> Best to see would be a fiddler2 trace.
>
> In the .NET SDK we run all strings we send through the UTF8 encoder  
> before we write them. And that seems to work just fine. The default  
> objects we create to send around include those unicode chars:
>
>   AtomEntry entry = new AtomEntry();
>              // some unicode chars
>              Char[] chars = new Char[] {
>              '\u0023', // #
>              '\u0025', // %
>              '\u03a0', // Pi
>              '\u03a3',  // Sigma
>              '\u03d1', // beta
>              '&',
>              };
>
>              AtomPerson author = new AtomPerson(AtomPersonType.Author);
>              author.Name = "John Doe" + chars[0] + chars[1] + chars[2]  
> + chars[3] + chars[4] + chars[5];
>
> and we use that name as the default to verify we can send this around  
> safely. It get's persisted as:
>
>   <author>
>      <name>John Doe#%ΠΣ</name>
>      <email>[email protected]</email>
>    </author>
>
> on the wire, i think the main difference is that the .NET sdk sends  
> this as well in the http headers:
>
> Content-Type: application/atom+xml; charset=UTF-8
>
> Frank Mantek
> Google
>
> On Feb 22, 2009, at 7:24 PM, BlackToe wrote:
>
>
>
> > What are you using to post the request to Google API?  I'm using
> > the .NET HttpWebRequest and writing the XML content using a
> > StreamWriter.  I've even tried specifying UTF-8 encoding when writing
> > the content, with no luck.  I've logged my XML to a file, and the "ø"
> > character appears correctly in the log.
>
> > Interestingly, the XML parser in IE does not consider my XML valid,
> > reporting the "ø" an invalid character 
> > (openhttp://www.planyourdive.com/google_api_problem.xm
> > l
> > in IE to see).  Firefox will display it, but renders the "ø" as an
> > unknown character.
>
> > My guess is that something is munging the "ø" between me and Google,
> > such that Google considers the XML invalid, but I can't figure out
> > what would be doing that.  Is there any way to see what Google
> > received on their end?
>
> > On Feb 21, 9:50 pm, Ray Baxter <[email protected]> wrote:
> >> Oh, and the "ø" character appears correctly in the first event, but  
> >> in the
> >> second it appears as it did in your posting, as an unknown unicode
> >> character.
> >> Ray
>
> >> On Sat, Feb 21, 2009 at 9:48 PM, Ray Baxter <[email protected]>  
> >> wrote:
> >>> I created an event using your xml. Here it is:
>
> >>>http://www.google.com/calendar/event?eid=Y24xbmhtbjJmNTRjbXBmMnBncjhu
> >>> ...
>
> >>> here's a tiny urlhttp://tinyurl.com/c9lrwn
>
> >>> You see that the "ø" character appears without problem. I'm not  
> >>> otherwise
> >>> doing anything special.
>
> >>> By the way, I took the data from your previous post, changed the  
> >>> date to
> >>> the 22nd so we could see what was happening, and removed some line  
> >>> breaks
> >>> and stray html and was also able to create an event:
>
> >>>http://www.google.com/calendar/event?eid=ZnMxdGRldmdpZmRwYWhhdmRqYmQw
> >>> ...
>
> >>> Hope that helps.
>
> >>> Ray
>
> >>> On Sat, Feb 21, 2009 at 7:39 PM, BlackToe  
> >>> <[email protected]
> >>>> wrote:
>
> >>>> You bet.  I posted an XML file at
> >>>>http://www.planyourdive.com/google_api_problem.txt.
>
> >>>> On Feb 20, 6:38 pm, Trevor Johns <[email protected]> wrote:
> >>>>> On Fri, Feb 20, 2009 at 8:51 AM, BlackToe
>
> >>>>> <[email protected]> wrote:
>
> >>>>>> It seems like my posts take forever to show up on this thread.
> >>>>>> Anyway...
>
> >>>>> That's because I have to moderate everything manually. This group
> >>>>> would get a lot of spam otherwise. :(
>
> >>>>>> I added an XML declaration with UTF-8 encoding, and still got  
> >>>>>> the same
> >>>>>> problem.  Here's the XML (with some irrelevant info removed).  
> >>>>>> The
> >>>>>> offending character is the "o" with a slash through it in
> >>>>>> "Strandmollen".
>
> >>>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>>> <entry xmlns="http://www.w3.org/2005/Atom"; xmlns:gd="http://
> >>>>>> schemas.google.com/g/2005">
> >>>>>>  <category scheme="http://schemas.google.com/g/2005#kind";
> >>>>>> term="http://schemas.google.com/g/2005#event"; />
> >>>>>>  <title type="text">Strandm llen</title>
> >>>>>>  <content type="html">If you make changes to this event,
> >>>>>> PlanYourDive.com will no longer be able to sync it.&lt;/p&gt;</
> >>>>>> content>
> >>>>>>  <gd:transparency value="http://schemas.google.com/g/
> >>>>>> 2005#event.opaque" />
> >>>>>>  <gd:eventStatus value="http://schemas.google.com/g/
> >>>>>> 2005#event.confirmed" />
> >>>>>>  <gd:where valueString="Strandm llen" />
> >>>>>>  <gd:when startTime="2009-02-23T20:00:00.000Z"
> >>>>>> endTime="2009-02-23T20:00:00.000Z" />
> >>>>>> </entry>
>
> >>>>> Those characters are getting munged by either SMTP or Google  
> >>>>> Groups.
> >>>>> Would you try posting that information in a .txt file hosted  
> >>>>> somewhere
> >>>>> off-list (then posting the URL) so I can try to reproduce this  
> >>>>> on my
> >>>>> end?
>
> >>>>> --
> >>>>> Trevor Johns

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to