Results 1 to 5 of 5

Thread: **SOLVED**Delete first Byte of a File // Read last Post

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Unhappy **SOLVED**Delete first Byte of a File // Read last Post

    Hey all, i have a small problem and just cant find any solution to it.


    I am creating a Xml Document and save this one with doc.save(path) This works all right, but I need the file to be saved UTF-8 encoded. I already have a encoding attribute in my Xml declaration, but c# doesn't seem to care about.

    So heres my question, how can I save the document UTF-8 encoded?

    Thanks in advance,


    Stephan
    Last edited by Sgt-Peppa; Aug 20th, 2003 at 09:13 AM.
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Code:
    XmlDocument xmlDoc = new XmlDocument();
    XmlNode encoding = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", String.Empty);
    xmlDoc.AppendChild(encoding);

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    I am sorry, this is not working! I already have a xmldeclaration in my Document which already contains the encoding="UTF-8". But still, if I save myXmlDoc.save(path); it saves it as whatever, but not UTF-8.

    Is it possible to Convert my XmlDom to a byte array, encode that one and then save it with a Streamwriter? And how?

    Or is there any other way of getting my XmlDoc UTF-8 encoded?

    Thanks,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Hey, well i finally figuerd that one out, but have a new related problem:

    Testing my Files I found out that my Xml Document definitely is UTF-8 Encoded. My Problem is that Microsoft usues a different UTF-8 Standard than java. The file creted from my C# function is supposed to be passed on to a java app. C# addes one byte at the beginnin of the document, java cant use.

    NEW QUESTION: How can I open a file Binary and delete the first byte?

    Thanks Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  5. #5

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    found a workaround thanks anyways

    I just passed the xmldom as String to a StreamWriter which writes the doc without encoding!

    Thanx anyways, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width