Unicode - ASCII ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • N

    #1

    Unicode - ASCII ?

    Hi,
    I'm writing a small web service (using C#) which is going to receive a text
    file, add a line to it and send it back.
    Input is a string with each line ending with "\r\n".
    The problem is in the format of the output - looks like all ends of lines
    are missing, even if web service just receives and sends back the same
    string.

    Could it be some encoding issue?

    Thanks in advance!

  • Dan Rogers

    #2
    RE: Unicode - ASCII ?

    Hi,

    The likely issue is that in XML, an end of line is considered white-space.
    Each end of an XML processing pair has the option of making their
    processors ignore white-space, and I suspect that your choice of trying to
    treat multiple records like there were one element is at the root of the
    problem.

    Have you thought about either using Soap with attachments to transfer the
    file in/out, or using a data structure more suitable to passing multiple
    records > (e.g. something like this from an on-the-wire perspective?)

    <myFile>
    <record number="1">the quick brown fox jumped over the lazy dog</record>
    <record number="2">ever y good boy deserves fudge</record>
    </myFile>

    you could easliy create a class from the following schema fragment that you
    would then pass as the input and output type, and you 'd get away from all
    of those platform/caller specfic white-space processing rules...

    <xs:complexTy pe name="myFile">
    <xs:complexCont ent>
    <xs:sequence>
    <xs:element name="record" type="xs:string " minOccurs="0"
    maxOccurs="unbo unded"/>
    </xs:sequence>
    <xs:complexCont ent>
    </xs:complexType>

    Throw that in a schema, run it thru XsdObjectGen.ex e and you'll have
    classes that implement the collection of records. It may not be the file
    you had in mind, but a simple file/reader to collection to web call back to
    file wrapper is pretty straight forward. Optionally, just make the
    resulting XMl the desired file format in the first place, and you can load
    the data to be passed as a myFile class type directly in 2 lines.

    I hope this helps

    Dan Rogers
    Microsoft Corporation

    --------------------
    Thread-Topic: Unicode - ASCII ?
    thread-index: AcTs/JSY4Pj/8/U2SfGKkqY/YUfuqQ==
    X-WBNR-Posting-Host: 208.4.218.82
    From: "=?Utf-8?B?Tg==?=" <N@discussions. microsoft.com>
    Subject: Unicode - ASCII ?
    Date: Tue, 28 Dec 2004 08:45:04 -0800
    Lines: 12
    Message-ID: <8C0B200C-A46A-4324-90A2-B0D60BD8CC15@mi crosoft.com>
    MIME-Version: 1.0
    Content-Type: text/plain;
    charset="Utf-8"
    Content-Transfer-Encoding: 7bit
    X-Newsreader: Microsoft CDO for Windows 2000
    Content-Class: urn:content-classes:message
    Importance: normal
    Priority: normal
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    Newsgroups: microsoft.publi c.dotnet.framew ork.webservices
    NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.1.29
    Path: cpmsftngxa10.ph x.gbl!TK2MSFTNG XA03.phx.gbl
    Xref: cpmsftngxa10.ph x.gbl
    microsoft.publi c.dotnet.framew ork.webservices :8326
    X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.webservices

    Hi,
    I'm writing a small web service (using C#) which is going to receive a text
    file, add a line to it and send it back.
    Input is a string with each line ending with "\r\n".
    The problem is in the format of the output - looks like all ends of lines
    are missing, even if web service just receives and sends back the same
    string.

    Could it be some encoding issue?

    Thanks in advance!


    Comment

    Working...